/*convert decimal to binary */
#include<stdio.h>
#include<conio.h>
void main()
{
int a=1,rem,bin=0,num;
clrscr();
printf("Enter decimal number :");
scanf("%d",&num);
while(num>0)
{
rem=num%2;
bin+=(rem*a);
num/=2;
a*=10;
}
printf("binary =%d",bin);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a=1,rem,bin=0,num;
clrscr();
printf("Enter decimal number :");
scanf("%d",&num);
while(num>0)
{
rem=num%2;
bin+=(rem*a);
num/=2;
a*=10;
}
printf("binary =%d",bin);
getch();
}
No comments:
Post a Comment