codescracker


c

C Program to Convert Octal to Decimal



« Previous Program Next Program »


Octal to Decimal Conversion in C

To convert octal number to decimal number in C programming, you have to ask to the user to enter the octal number to convert it into decimal number to display the equivalent value in decimal form.

C Programming Code to Convert Octal to Decimal

Following C program ask to the user to enter any octal number to convert it into decimal, then display the result on the screen :

/* C Program - Octal to Decimal Conversion */
		
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
	clrscr();
	long int octnum, decnum=0;
	int i=0;
	printf("Enter any Octal Number : ");
	scanf("%ld",&octnum);
	while(octnum!=0)
	{
		decnum = decnum + (octnum%10) * pow(8, i);
		i++;
		octnum=octnum/10;
	}
	printf("Equivalent Decimal Value = %ld",decnum);
	getch();
}

When the above c program is compile and executed, it will produce the following result:

c program convert octal to decimal

Same Program in Other Programming Language

You may also like same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test