十进制数转换为二进制数
#include<stdio.h>
#define N 100
int main()
{
int container[N];
int num,quotient,residue;//商和余数
int i=0;
printf("please input a positive integer: ");
scanf("%d",&num);
quotient=num/2;
residue=num%2;
while(quotient!=0)
{
container[i++]=residue;
num=quotient;
quotient=num/2;
residue=num%2;
}
container[i]=residue;
printf("the bin of the num is: ");
for(;i>-1;i--)
printf("%d",container[i]);
printf("\n");
return 0;
}