C program to convert Octal number to Decimal Number
Simple C program to convert Octal number to Decimal Number
Code:
#include <stdio.h>#include<conio.h>
#include <math.h>
int main()
{
long long octal, tempOctal, decimal;
int rem, place;
printf("Enter any octal number: ");
scanf("%lld", &octal);
tempOctal = octal;
decimal = 0;
place = 0;
while(tempOctal!=0)
{
rem = tempOctal % 10;
decimal += pow(8, place) * rem;
tempOctal /= 10;
place++;
}
printf("\nOctal number = %lld\n", octal);
printf("Decimal number = %lld", decimal);
getch();
}
Comments
Post a Comment