Thursday, April 3, 2014

PROGRAM TO CONVERT A DECIMAL NUMBER INTO BINARY NUMBER(NUMBER SHOULD BE A WHOLE NUMBER)

//PROGRAM TO CONVERT A DECIMAL NUMBER INTO BINARY NUMBER(NUMBER SHOULD BE A WHOLE NUMBER)

#include<stdio.h>
#include<conio.h>
void main()
{
int a[50],n,i,t;
clrscr();
printf("enter the number\n");
scanf("%d",&n);
t=n;
for(i=0;n>=1;i++)
{
a[i]=n%2;
n=n/2;
}
printf("the binary representation of %d is ",t);
for(i=i-1;i>=0;i--)
printf("%d",a[i]);
getch();

No comments:

Post a Comment