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 format as shown here in the following program.

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<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
	clrscr();
	long int octnum, decnum=0;
	int i=0;
	cout<<"Enter any Octal Number : ";
	cin>>octnum;
	while(octnum!=0)
	{
		decnum = decnum + (octnum%10) * pow(8, i);
		i++;
		octnum=octnum/10;
	}
	cout<<"Equivalent Decimal Value = "<<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 Language

You may like the same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test