Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I am trying to figure out what is wrong with this code, it is not compili

ID: 3569564 • Letter: H

Question

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 <stdio.h>
#include <math.h>
#include <string.h>
void decimal_hex(int n, char hex[]);
int hex_decimal(char hex[]);
int main()
{
char hex[20];
int n;
printf("Instructions: ");
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]='';
strrev(hex); /* Reverse string */
}

Explanation / Answer

A=0;
x=0;
n=input('How many variables=');
disp('Enter the coefficients along with constants For instance if x+y+3z=-5 then enter 1 1 3 -5 each number followed by an enter not space');
for i=1:n
   for j=1:n+1
       A(i,j)=input('');
   end
end
%pivoting
for i=1:n-1
   for j=i+1:n
       if abs(A(j,i))>abs(A(i,i))
           T=A(j,:);
           A(j,:)=A(i,:);
           A(i,:)=T;
       end
   end
end
disp('After pivoting');
disp(A);
for k=1:n-1
   for i=k+1:n
       m=A(i,k)/A(k,k);
       for j=k:n+1
           A(i,j)=A(i,j)-m*A(k,j);
       end
   end
end
disp('Triangularize Form ');
disp(A);
           
if A(n,n)==0
   disp('No unique solution');
end
   x(n)=A(n,n+1)/A(n,n);
   for j=n-1:-1:1
       sum=0;
   for i=1:n
       sprintf('x%.0f=%.10f',i,x(i))
   end
       

       for i=1:n-j
           sum=sum+A(j,n+1-i)*x(n+1-i);
       end
       x(j)=(A(j,n+1)-sum)/A(j,j);
   end   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote