Write a program in C++ to convert a decimal number into binary by using the single inheritance 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 |
#include <iostream> using namespace std; class decimal { public: int i=1,j=n,n,Decimal_No=n,Binary_No=0; }; class T4Tutorials_Child:public decimal { public: int deci() { cout<<"decimal number"; cin>>n; } int bin() { for(j=n;j>0;j=j/2) { Binary_No=Binary_No+(n%2)*i;
i=i*10; n=n/2; } cout<<("Binary_No=",Decimal_No,Binary_No); } }; int main() { T4Tutorials_Child A; A.deci(); A.bin(); } |
Output
Please decimal number. 5
101
FAQ
program to convert decimal to binary in c++ by using the single inheritance in object-oriented programming.
C++ program to convert decimal to binary without using array by using the single inheritance in object-oriented programming.
C++ program to convert decimal to binary using class by using the single inheritance in object-oriented programming.
Convert an integer to binary by using the single inheritance in object-oriented programming.
Develop a c++ program to convert decimal numbers to binary by using the single inheritance in object-oriented programming.
Dev C++ convert decimal to binary by using the single inheritance in object-oriented programming.
decimal to binary c++ OOP by using the single inheritance in object-oriented programming.
Decimal to binary Example with single inheritance in object-oriented programming.