Logo 
Search:

C Programming Answers

Ask Question   UnAnswered
Home » Forum » C Programming       RSS Feeds
  Question Asked By: Jayanth Bijapuri   on May 15 In C Programming Category.

  
Question Answered By: Abhishek Singh   on May 15

#include<stdio.h>
#include<conio.h>
int main()
{
int a[20];
int dec,i=0;
printf("Enter the decimal number to find its binary number\n");
scanf("%d",&dec);
while(dec>0)
{
a[i]=dec%2;
i++;
dec=dec/2;
}
printf("Binary number of %d is = ",dec);

for(int j=i-1;j>=0;j--)
{
printf("%d",a[j]);
}
getch();
}

Share: