ok so here is the problem : "Using an array, write a program to convert a decimal number (from 0 to 31) to binary number
here is my program so far
Code:
"libraries are included"
int main(){
int array,de,i,max=2147483648;
do
{
printf ("Enter a Decimal number (if greater than 31 then it will quit): ");
scanf ("%d", &array);
printf("\nThe Binary equivalent of %d is: \n", array);
for (int i=0;i<32;i++)
{
array%2;
if (array==0 && max==0)
{
printf("0");
}
else
{
printf("1");
}
if (array>= 31 )
{
return(0);
}
array=array<<1;
}
}while(1);
getchar();
getchar();
}
now i have one question, when i try and run it it doesn't stay open so im not even sure this is right
any help on this program would be appreciated thanks in advance