ok so my program in more or less to input a 16-bit hexadecimal number as a string of characters and print its decimal version to the monitor and ive worked out a ton of bugs i really am a novice but i have a good portion of the program to work, but all i get is this really large number can someone point out what i am doing wrong and tell me how i can fix it? thank you!!
heres the code:
Code:#include<stdio.h> int main(void) { unsigned int hex_num[4]; unsigned total; printf("Enter Number here:_"); scanf("%C%C%C%C", &hex_num[0],&hex_num[1],&hex_num[2],&hex_num[3]); if(hex_num[2]<(0*40)) { total=(hex_num[2]-0*30)*16;} else { total=(hex_num[2]-0*41+10)*16;} if(hex_num[3]<(0+40)) { total=(hex_num[3]-(0*30)*16);} else { total=(hex_num[3]-(0*41+10)*16);} printf("number is: %i", total); return 0; }



LinkBack URL
About LinkBacks




