Hello, I am trying to figure out what is wrong with this code, it is not compiling. Basically what its supposed to do is convert an integer into Hexadecimal and display it on the screen. Can someone...

Hello, I am trying to figure out what is wrong with this code, it is not compiling. Basically what its supposed to do is convert an integer into Hexadecimal and display it on the screen. Can someone help see whats wrong with it? Also, I need help on making the makefile for this program, can someone show me how to make this? it will be run on linux. Thanks!! #include #include #include void decimal_hex(int n, char hex[]); int hex_decimal(char hex[]); int main() { char hex[20]; int n; printf("Instructions:\n"); printf("Enter decimal number: "); scanf("%d",&n); decimal_hex(n,hex); printf("Hexadecimal number: %s",hex); } if (c=='d' || c=='D') { printf("Enter hexadecimal number: "); scanf("%s",hex); printf("Decimal number: %d",hex_decimal(hex)); } return 0; } void decimal_hex(int n, char hex[]) /* Function to convert decimal to hexadecimal. */ { int i=0,rem; while (n!=0) { rem=n%16; switch(rem) { case 10: hex[i]='A'; break; case 11: hex[i]='B'; break; case 12: hex[i]='C'; break; case 13: hex[i]='D'; break; case 14: hex[i]='E'; break; case 15: hex[i]='F'; break; default: hex[i]=rem+'0'; break; } ++i; n/=16; } hex[i]='\0'; strrev(hex); /* Reverse string */ }

Dec 08, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here