Menu Close

One’s Complement of an Integer | C++

Programming with C++ | Bottom Science
#include<iostream>
#include<cmath>
using namespace std;

int main() 
          {
             cout<< "PROGRAM TO CONVERT OCTAL NUMBER TO DECIMAL [ BY - WWW.BOTTOMSCIENCE.COM ] \n"; 
             cout<<"ENTER THE OCTAL NUMBER \n";
             int dec = 0, i = 0, rem, onum;
             cin>>onum;
             
             while (onum != 0)
                              {
                                 rem = onum % 10;
                                 onum /= 10;
                                 dec += rem * pow(8, i);
                                 ++i;
                              }

             cout<<"\n THE DECIMAL CONVERSION IS:\n"<<dec;

             return 0;

            }
 

OUTPUT

/tmp/O6Mdp4eN8Y.o
PROGRAM TO CONVERT OCTAL NUMBER TO DECIMAL [ BY - WWW.BOTTOMSCIENCE.COM ] 
ENTER THE OCTAL NUMBER 
101
THE DECIMAL CONVERSION IS:
65

More Related Stuff