C++ Inline function Binary to octal conversion
Write a C++ program of binary to octal conversion with inline function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* binary to octal conversion with inline function*/ #include<iostream> using namespace std; class T4Tutorials { private : int i,j,dn; int temp,T4Tutorials_Octal; public : int conv(); }; inline T4Tutorials::conv() { cout<<".Program for decimal to octal Conversion "<<endl; cout<<"Using InLine Function."<<endl; cout<<"Enter the octal Number : "<<endl; cin>>dn; temp=dn; i=1; for(j=dn ; j>0 ; j=j/8) { T4Tutorials_Octal=T4Tutorials_Octal+(j%8)*i; i=i*10; } cout<<"Your Input Decimal is :"<<temp; cout<<"Octal Value After conversion is : "<<T4Tutorials_Octal<<endl; } int main() { T4Tutorials a; a.conv(); } |