Hello guys I am suppose to write a code to convert unasigned decimal to binary a
ID: 3741794 • Letter: H
Question
Hello guys
I am suppose to write a code to convert unasigned decimal to binary and suppose to follow this alogorithm
· Quotient=N
· i=0
· di=quotient=quotient % 22
· quotient=quotient / 2
· While quotient0
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 the proffesor. What is wrong?