Write a program in C++ to convert a decimal number into binary by using the Class Objects 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 |
#include <iostream> using namespace std; class decimal { private: int i=1,j=n,n,T4Tutorials_decimal=n,T4Tutorials_binary=0; public: int deci() { cout<<"decimal number"; cin>>n; } int bin() { for(j=n;j>0;j=j/2) { T4Tutorials_binary=T4Tutorials_binary+(n%2)*i; i=i*10; n=n/2; } cout<<("T4Tutorials_binary=",T4Tutorials_decimal,T4Tutorials_binary); } }; int main() { decimal A; A.deci(); A.bin(); } |
Output
Please decimal number. 8
1000
FAQ
FAQ
Program to convert decimal to binary in C++ by using the classes and objects in object-oriented programming.
C++ program to convert decimal to binary without using array by using the classes and objects in object-oriented programming.
C++ program to convert decimal to binary using class by using the classes and objects in object-oriented programming.
Convert integer to binary by using the classes and objects in object-oriented programming.
Develop a C++ program to convert decimal numbers to binary by using the classes and objects in object-oriented programming.
Dev C++ converts decimal to binary by using the classes and objects in object-oriented programming.
Decimal to binary C++ oop by using the classes and objects in object-oriented programming.
Decimal to binary Example with classes and objects in object-oriented programming.