2014-09-19

Write a C program to convert a decimal number into a binary number

99% of the people who attend interviews can't answer this question, believe me!. Here is a C program which does this....

Programming Code

#include<stdio.h>
generatebits(int num)
{
int temp;
if(num)
{
temp = num % 2;
bit(num >>= 1);
printf("%d",temp);
}
}
int main()
{
int num;
while(1)
{
scanf("Enter a number : %d",&num);
printf("\n\n");
generatebits(num);
}
getch();
return(0);
}

0 comments:

Post a Comment

Tools & Plugins

Blog Archive