C Program to Convert Hexadecimal to Decimal
Write C Program to Convert Hexadecimal to Decimal
// Write C Program to convert Hexadecimal to Decimal #include <stdio.h> #include <math.h> int main() { int n, ans = 0; printf("Enter the Hexadecimal number :--> "); scanf("%d", &n); int i = 0; while(n != 0) { int digit = n % 10; ans = ans + (digit* pow(16,i)); n = n / 10; i++; } printf("The Decimal number is :--> %d",ans); return 0; }
Output:
Enter the Hexadecimal number :--> 658
The Decimal number is :--> 1624