Decimal number:
Consists of 10 elements
range : 0 to 9
Hexadecimal number :
Consists of 16 elements
range : 0 to 9 then 'A' to 'F'
Hexadecimal to Decimal conversion:
Example-
Hexadecimal number is A
Decimal number is 10
Hexadecimal number is E
Decimal number is 15
Hexadecimal number is 92
Decimal number is 41
program-
#include< stdio.h>
#include< math.h>
int main() {
int n,num=0,i=0,sum=0;
printf("Enter Hexadecimal number\n");
scanf("%d",&n);
while(n)
{
num=n%10;
num=num*pow(16,i++);
sum=sum+num;
n=n/10;
}
printf("It's Decimal is %d",sum);
}
Enter Hexadecimal number
41
It's Decimal is 65