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
Compare array data type to pointer data type
What is preprocessor with example?
Is that possible to store 32768 in an int data type variable?
Can you tell me how to check whether a linked list is circular?
WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.
Explain why C language is procedural?
what are bit fields? What is the use of bit fields in a structure declaration?
Difference between constant pointer and pointer to a constant.
How can you tell whether two strings are the same?
What is hungarian notation? Is it worthwhile?
What is the difference between malloc calloc and realloc in c?
Does c have enums?
write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.
What does node * mean?
What is the meaning of typedef struct in c?