C program to convert octal into decimal.

 

01  #include <stdio.h>
02 #include <math.h>
03
04 int main()
05 {
06 long octalNumber, decimalNumber=0;
07 int remainder,i=1;
08
09 printf("Enter an Octal Number : ");
10 scanf("%ld", &octalNumber);
11
12 while(octalNumber!=0)
13 {
14 remainder = octalNumber%10;
15 decimalNumber += remainder*i;
16 octalNumber /= 10;
17 i=i*8;
18 }
19
20 printf("Decimal Number : %ld", decimalNumber);
21 return 0;
22 }
 
 OUTPUT :

Enter any Octal number : 256
Decimal Number : 174

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.