Multi-Level inheritance C++ program to convert a decimal number to hexadecimal
C++ program to convertĀ decimal to hexadecimal using Multi-Level Inheritance
Write a program in C++ to convert a decimal number to hexadecimal using the Multi-Level Inheritance in object-oriented programming (OOP).
Develop a C++ program to convert a decimal value to hexadecimal value using the Multi-Level 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 |
#include<iostream> using namespace std; class T4Tutorials_Grand_Parent { protected: int dec,remd,q,m; char s; }; class T4Tutorials_Parent:public T4Tutorials_Grand_Parent { protected: int l,temp; }; class T4Tutorials_Child:public T4Tutorials_Parent { public: int conversion() { cout<<"enter the decimal no"; 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(); } |
Output
enter any decimal no 11
hexadecimal no=B
FAQ
C++ decimal to hex string using the Multi-Level Inheritance.
decimal to hexadecimal in C++ without using array using the Multi-Level Inheritance.
C++ program to convert decimal to hexadecimal using for loop using the Multi-Level Inheritance.
hexadecimal to decimal C++ using the Multi-Level Inheritance.
decimal to hexadecimal example problems using the Multi-Level Inheritance.