7/*Write a C program to convert given decimal number into binarynumber.*/


#include<stdio.h>
#include<conio.h>
void main()
{
int k=0,n,i,rem,x[10];
clrscr();
printf(“\n\n Enter the decimal number:\n”);
scanf(“%d”,&n);
while(n!=1)
{
rem=n%2;
x[k]=rem;
n=n/2;
k++;
}
x[k]=1;
printf(“\n The binary equivalent is:”);
for(i=k;i>=0;i–)
printf(“%d”,x[i]);
getch();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s