Write a program in C++ to convert a decimal number into binary by using the multiple inheritances in object-oriented programming.
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 |
#include <iostream> using namespace std; class T4Tutorials_Parent1 { protected: int i,j,n; }; class T4Tutorials_Parent2 { protected: int decimalnumber,binarynumber; }; class child:public T4Tutorials_Parent1,public T4Tutorials_Parent2 { public: int deci() { i=1,n,decimalnumber=n,binarynumber=0; cout<<"decimal number"; cin>>n; } int bin() { for(j=n;j>0;j=j/2) { binarynumber=binarynumber+(n
%2)*i; i=i*10; n=n/2; } cout<<("binarynumber=",decimalnumber,binarynumber); } }; int main() { child A; A.deci(); A.bin(); } |
Output
Please decimal number. 6
110
FAQ
Program to convert decimal number to binary number in C++ by using the Multiple inheritance in object-oriented programming.
C++ program to convert decimal number to binary number without using array by using the Multiple inheritance in object-oriented programming.
C++ program to convert decimal number to binary number using class by using the Multiple inheritance in object-oriented programming.
Convert integer to binary by using the Multiple inheritance in object-oriented programming.
Develop a C++ program to convert decimal numbers to binary by using the Multiple inheritance in object-oriented programming.
Dev C++ converts decimal number to binary number by using the Multiple inheritance in object-oriented programming.
Decimal number to binary number C++ oop by using the Multiple inheritance in object-oriented programming.
Decimal number to binary number Example with Multiple inheritance in object-oriented programming.