C++ program to convertĀ decimal to hexadecimal using Single inheritance
Write a program in C++ to convert a decimal number to hexadecimal using the single inheritance in object-oriented programming (OOP).
Develop a C++ program to convert a decimal value to hexadecimal value using the single inheritance in OOP.
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 | #include<iostream> using namespace std; class T4Tutorials_Parent { protected: int dec,remd,q,m,l,temp; char s; }; class T4Tutorials_child: public T4Tutorials_Parent { public: int conversion() { cout<<"enter any decimal no"<<endl; cin>>dec; q=dec; for(l=q; l>0; l=l/16) { temp=l%16; if(temp<10) temp=temp+48; else temp=temp+55; dec=dec*100+temp; } cout<<"hexadecimal no="; for(m=dec; m>0; m=m/100) { s=m%100; cout<<" "<<s; } } }; int main() { T4Tutorials_child myobj; myobj.conversion(); cout<<endl; return 0; } |
Output
enter any decimal no 10
hexadecimal no=A
FAQ
C++ decimal to hex string using the single inheritance.
decimal to hexadecimal in C++ without using array using the single inheritance.
C++ program to convert decimal to hexadecimal using for loop using the single inheritance.
hexadecimal to decimal C++ using the single inheritance.
decimal to hexadecimal example problems using the single inheritance.