WELCOME TO MY BLOG BY SHABEEB.K

C,C++ PROGRAMMING: CONVERT DECIMAL NUMBER TO BINARY

Search This Blog

Saturday, 3 August 2013

CONVERT DECIMAL NUMBER TO BINARY


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,k=0,b[10],i=0;
clrscr();
printf("ENTER A NUMBER\n");
scanf("%d",&n);
while(n>0)
{
b[i]=n%2;
n=n/2;
i++;
k++;
}
for(i=k-1;i>=0;i--)
{
printf("%d",b[i]);
}
getch();
}


OUTPUT


No comments:

Post a Comment