Tuesday, October 16, 2012

Program To Convert a Number into Binary



Some Basic C program frequently asked in Interview.

/*Program to convert a number into Binary*/

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter a number:\t");
scanf("%d",&a);
printf("\t");                  //'\t' is for tab 
while(a>0)
{
b=a%2;
printf("%d",b);
printf("\b\b");         // '\b' is for backspace
a=a/2;
}
getch();
}

No comments: