You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-examples/c/Basic/C Program to Convert Octal ...

21 lines
436 B
C

/*
* C Program to Convert Octal to Decimal
*/
#include <stdio.h>
#include <math.h>
int main()
{
long int octal, decimal = 0;
int i = 0;
printf("Enter any octal number: ");
scanf("%ld", &octal);
while (octal != 0)
{
decimal = decimal +(octal % 10)* pow(8, i++);
octal = octal / 10;
}
printf("Equivalent decimal value: %ld",decimal);
return 0;
}