program:
#include <stdio.h>
#include <math.h>
long long con(int octalNum);
int main()
{
int octalNum;
printf("Enter an octal number: ");
scanf("%d", &octalNum);
printf("%d in octal = %lld in decimal", octalNum, con(octalNum));
return 0;
}
long long con(int octalNum)
{
int decimalNum = 0, i = 0;
while(octalNum != 0)
{
decimalNum += (octalNum%10) * pow(8,i);
++i;
octalNum/=10;
}
i = 1;
return decimalNum;
}
output: