how to convert binary to decimal and decimal to binary in C
lanaguage
Answer Posted / ruchi
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int n,r,s=0,i=0;
printf("\nEnter the decimal number ");
scanf("%d",&n);
while(n>0)
{
r=n%2;
n=n/2;
s=s+r*pow(10,i++);
}
printf("\nThe binary equivalent is ");
printf("%d",s);
getch();
}
| Is This Answer Correct ? | 27 Yes | 17 No |
Post New Answer View All Answers
Explain what will the preprocessor do for a program?
Explain modulus operator.
What is a file descriptor in c?
What does malloc () calloc () realloc () free () do?
What is #line?
how to count no of words,characters,lines in a paragraph.
What is the size of structure in c?
Explain how do you determine whether to use a stream function or a low-level function?
What is the correct code to have following output in c using nested for loop?
What is the difference between malloc() and calloc() function in c language?
What is structure padding and packing in c?
Explain b+ tree?
What do you mean by c what are the main characteristics of c language?
what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555
Array is an lvalue or not?