Logo 
Search:

C Programming Forum

Ask Question   UnAnswered
Home » Forum » C Programming       RSS Feeds

binary

  Asked By: Jayanth    Date: Jan 06    Category: C Programming    Views: 1817
  

write a program to convert decimal to binary and binary to decimal

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Abhishek Singh     Answered 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();
}

 
Didn't find what you were looking for? Find more on binary Or get search suggestion and latest updates.




Tagged: