Course Solutions Uncategorized (Solved) : Hello Guys Suppose Write Code Convert Unasigned Decimal Binary Suppose Follow Alogorithm Q Q30757017 . . . .

(Solved) : Hello Guys Suppose Write Code Convert Unasigned Decimal Binary Suppose Follow Alogorithm Q Q30757017 . . . .

 

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”,&quotient);

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. . . . .

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

(Solved) : Criteria Ontela Picdeck B Use Provide Risk Adjusted Recommendations Segments Potential Wir Q30269753 . . . .(Solved) : Criteria Ontela Picdeck B Use Provide Risk Adjusted Recommendations Segments Potential Wir Q30269753 . . . .

<p>What criteria should Ontela PicDeck B use to providerisk-adjusted recommendations on segments potential wirelessproviders should target?</p><p>Create positioning statements for your top 2 segments.</p><p><img alt="Exhibit 4: Demographic and Media Profile of