Skip to main content

Featured

functions in Python

C++ program to convert octal to decimal

/*Following program converts Octal Number to its Decimal        Equivalent
*/
#include<iostream.h>
#include<conio.h>
#include<math.h>
void octal2dec(long num)
{
int i=0,rem;
long sum=0;

     while(num>0)
{
rem=num%10;
sum=sum+rem*pow(8,i);
i++;
num=num/10;
}
cout<<"Decimal Equivalent is<< "<<sum;
}
void main()
{
clrscr();
long n;
cout<<"\nEnter An Octal Number\n";
cin>>n;
octal2dec(n);
getch();
}
OUTPUT:

Comments

Popular Posts