Hello guys
I am suppose to write a code to convert unasigned decimal tobinary and suppose to follow this alogorithm
· Quotient=N
· i=0
· di=quotient=quotient% 22
· quotient=quotient/ 2
· Whilequotient≠0
o i=i+1
o di=quotient %22
o quotient=quotient/ 2
This is what i have so far
#include <stdio.h>
int main(void)
{
int quotient,i,j, bin[64];
printf(” Please enter decimal number: “);
scanf(“%d”,"ient);
i=0;
while(quotient!=0)
{
bin[i]=quotient%2;
quotient=quotient/2;
i=i+1;
}
printf(” The Binary value is: “);
for(j=(i-1); j>=0;j–)
printf(“%d”,bin[j]);
return 0;
}
It compiles, but fails the 4 test cases assigned by theproffesor. What is wrong?
Expert Answer
An answer will be send to you shortly. . . . .