So I got the program all set up and it works. But only if I use int. Whenever I used unsigned int or unsigned long long int, the program constantly spits out 0 or 1 on to the screen nonstop. Here is what I have so far:
Code:
#include <stdio.h>
int main()
{
int a, b, d, c[36]={0}, i;
i=0;
printf("BASE 10 TO BASE 2 CONVERTER\n\n");
printf("Enter the base 10 number:");
scanf("%d", &a);
d=a;
while (a!=0)
{
b=a%2;
a=a/2;
c[i]=b;
i++;
}
printf("\"%d\" in base 10 is equal to \"", d);
for(i=i-1; i>=0; i--)
printf("%d", c[i]);
printf("\" in base 2\n");
return 0;
}
The problem I also run into is creating an array using unsigned long long int, then trying to set b, an unsigned long long int, to c[i], which is an unsigned int or whatever.
Also what does recursive mean? I never learned about that.