C Program To Convert Decimal to Binary

#include<stdio.h>
#include<conio.h>
void main()
{
int n, digit,i=0,j;
int bdigit[16];
clrscr();
printf("Enter Decimal number:");
scanf("%d",&n);
while(n>0)
{
digit=n%2;
bdigit[i]=digit;
++i;
n=n/2;
}

for(j=i-1;j>=0;j--)
printf("  %d", bdigit[j]);
getch();
}
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment