Decimal number:
Consists of 10 elements
range : 0 to 9
Octal number :
Consists of 8 elements
range : 0 to 7
Octal to Decimal conversion:
Example-
Octal number is 7
Decimal number is 7
Octal number is 15
Decimal number is 41
program-
#include< stdio.h>
#include< math.h>
int main() {
int n,num=0,i=0,sum=0;
printf("Enter Octal number\n");
scanf("%d",&n);
while(n)
{
num=n%10;
num=num*pow(8,i++);
sum=sum+num;
n=n/10;
}
printf("It's Decimal is %d",sum);
}
Enter Octal number
41
It's Decimal is 33