Write a program in C++ to convert an octal number into binary using the Multiple inheritances.
Develop a C++ program to convert an octal number into binary using the Multiple inheritances.
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
//program octal to binary //mutiple inheritence program #include<iostream> using namespace std; class number { protected: int num,p=1; int decimal=0,i=1,j,d; }; class number2 { protected: int binary=0; }; class child:public number,public number2 { public: int show() { cout<<"enter octal(using digit 0__7):"; cin>>num; for(j=num; j>0; j=j/10) { d=j%10; if(i==1) p
=p*1; else p=p*8; decimal=decimal+(d*p); i++; } i=1; for(j=decimal; j>0; j=j/2) { binary=binary+(decimal%2)*i; i=i*10; decimal=decimal/2; } cout<<"octal number into binary number "<<binary; } }; int main
() { child c; c.show(); } |