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< stdio.h>
int main() {
int n,num=0;
printf("Enter decimal number\n");
scanf("%d",&n);
while(n)
{
num=num*10+n%16;
n=n/16;
}
printf("It's Hexadecimal is %d",num);
}
Enter decimal number
41
It's Hexadecimal is 92