Converting a short decimal into binary using a short, no libary.
I just want help, it doesnt do anthing past the printf statment.
I dont want anyone to write the whole thing for me.
As i said im just lost and dont know what to do
Thank you so very much
still new to C programming.
Code:
<stdio.h>
short inputnumber ; // the number taken from the user
int temp;
int j = 0; //counts the array loctions when printing
int count;// equals the number you entered
int i = 0;// counts the array loctions when it enters binary number
int binout[16] ={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};//
int _tmain(int argc, _TCHAR* argv[])
{
//Asked user for their number
printf("Please enter a number that is 16 bits\n");
//scans the user number
scanf_s("%i",&inputnumber);
count = inputnumber;//
// useing mod to check if there is a remainer adding 1 if 0 or 1 if its a 1 doing 2's comp
while ( count =! 0)
if (count % 2 == 0 )
{binout[i] = 1;
count = count / 2;
++i;}//
else (binout[i] = 0);
{count = count / 2;
++i;}
//changing the first bit to the oppisite 2's comp
if (binout[0] = 0)
{binout[0] = 1;}
else (binout[0] = 0);
// printing you're number in binary
while (j < 16, ++j )
{printf("You're number in 2's comp binary %i", &binout[j]);}
return 0;}