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