Showing posts with label Octal to Decimal. Show all posts
Showing posts with label Octal to Decimal. Show all posts

Wednesday, July 6, 2011

Program to convert the given octal number to the corresponding decimal number


#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
  clrscr();
  int n,num,t,d=0;
  cout<<" Enter the octal number:"<<endl;
  cin>>n;
  num=n;
  t=0;
  while(n>0)
  {
        d+=pow(8,t)*(n%10);
        n=n/10;
        t++;
  }
  cout<<" The decimal equivalent is"<<d<<endl;
  getch();
}