C Program to Convert Octal to Decimal

#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:


No comments:

Post a Comment

100 C Programs with Code and Output

Program 1: C Program To Read Two Numbers And Print The Sum Of Given Two Numbers. Program 2: C Program To Read Three Numbers And Prin...