Search This Blog

Octal to Decimal Converter Program - Program to Convert from Octal to Decimal

This is a c program to convert any Octal number to decimal number system. Octal number system represents numbers using digits 0 to 7. The decimal number system is the commonly used number system which uses digits 0 to 9. The following program performs conversion from octal to decimal.


#include<stdio.h> #include<string.h> int OctToDec(int oct) { int dec=0,base=1; int t; t=oct; while(t>0) { dec+=(t%10)*base; t/=10; base*=8; } return dec; } void main() { int input; printf("\nEnter the Octal number\n"); scanf("%d",&input); printf("Corresponding decimal number is: %d",OctToDec(input)); }

No comments: