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