how to convert binary to decimal and decimal to binary in C
lanaguage
Answer Posted / rahul
[decimal to binary]
#include<stdio.h>
#include<conio.h>
void main()
{
int dec,bin,a[100],i=0,r,j;
printf("enter the decimal number: ");
scanf("%d",&dec);
while(dec>0)
{
r=dec%2;
dec=dec/2;
a[i]=r;
i++;
}
printf("the equivalant binary numberis: ");
for(j=i-1;j>=0;j--)
printf("%d",a[j]);
getch()
}
| Is This Answer Correct ? | 72 Yes | 32 No |
Post New Answer View All Answers
Explain About fork()?
What are type modifiers in c?
Why header file is used in c?
What library is sizeof in c?
What is the most efficient way to store flag values?
Can we declare a function inside a function in c?
How can you draw circles in C?
what does static variable mean?
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.
What are the differences between Structures and Arrays?
which is an algorithm for sorting in a growing Lexicographic order
What is const keyword in c?
Explain built-in function?
What is calloc()?
Who developed c language?