Converting base 10 to base 2
Hey guys. I am doing an extra credit assignment where I need to convert any number from 0 to 18,446,744,073,709,551,615. I got down the basic layout to get base 10 into base 2, but backwards. Here is my code:
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,b;
printf("BASE 10 TO BASE 2 CONVERTER\n\n");
printf("Enter the base 10 number you want to convert:");
scanf("%d", &a);
while(a!=0)
{
b=a%2;
a=a/2;
printf("%d", b);
}
return 0;
}
So I have 2 questions.
1. How can I make "printf("%d", b);" to make it actually become a whole number instead of printing each number one by one? Would I use an array? If not an array, how would I reverse the numbers?
2. Which data type can I use to receive such a large input? Would I use an unsigned float maybe?