Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 27: Write a C++ program to convert octal number to decimal number.

#include<iostream>
#include<math.h>
using namespace std;

int main()
{
	int num,sum=0,j=0;
	cout<<"\nenter an octal number using digits(0-7) : ";
	cin>>num;

	for(int i=num;i>0;i=i/10)
	{
		sum+=(i%10)*pow(8,j);
		j++;
	}

	cout<<"\nafter conversion : \n\t\t< "<<num<<" >  =  < "<<sum<<" >";
	return 0;
}


If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.