Decimal number:
Consists of 10 elements
range : 0 to 9
Hexadecimal number :
Consists of 16 elements
range : 0 to 9 then 'A' to 'F'
Decimal to Hexadecimal conversion:
Example-
Decimal number is 10
Hexadecimal number is A
Decimal number is 15
Hexadecimal number is E
Decimal number is 41
Hexadecimal number is 92
program:
#include< iostream>
int main() {
int n,num=0;
cout<<"Enter decimal number"<< endl;
cin>>n;
while(n)
{
num=num*10+n%16;
n=n/16;
}
cout<<"It's Hexadecimal is "<< num;
}
Enter decimal number
41
It's Hexadecimal is 92