#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
long int octal_num, decimal_num=0;
int i=0;
printf("Enter any Octal Number : ");
scanf("%ld",&octal_num);
while(octal_num!=0)
{
decimal_num = decimal_num + (octal_num%10) * pow(8, i);
i++;
octal_num=octal_num/10;
}
printf("Equivalent Decimal Value = %ld",decimal_num);
getch();
}
Run1:
Run2:
Previous Next
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
long int octal_num, decimal_num=0;
int i=0;
printf("Enter any Octal Number : ");
scanf("%ld",&octal_num);
while(octal_num!=0)
{
decimal_num = decimal_num + (octal_num%10) * pow(8, i);
i++;
octal_num=octal_num/10;
}
printf("Equivalent Decimal Value = %ld",decimal_num);
getch();
}
Run1:
Run2:
Previous Next
No comments:
Post a Comment