/*
Program to to conver the decimal number to the binary equivalent
OS: UNIX or Windows
*/
#include<stdio.h>
void main()
{
int num,bin=0,rem,k=1;
printf("Enter the decimal number:\n");
scanf("%d",&num);
while(num!=0)
{
rem=num%2;
bin=bin+rem*k;
k=k*10;
num=num/2;
}
printf("Binary Equivqlent of a given number is %d\n",bin);
}
Program to to conver the decimal number to the binary equivalent
OS: UNIX or Windows
*/
#include<stdio.h>
void main()
{
int num,bin=0,rem,k=1;
printf("Enter the decimal number:\n");
scanf("%d",&num);
while(num!=0)
{
rem=num%2;
bin=bin+rem*k;
k=k*10;
num=num/2;
}
printf("Binary Equivqlent of a given number is %d\n",bin);
}
No comments:
Post a Comment