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
The file stdio.h, what does it contain?
define string ?
What is line in c preprocessor?
Explain how can you be sure that a program follows the ansi c standard?
What do the functions atoi(), itoa() and gcvt() do?
What is the advantage of an array over individual variables?
How do I get an accurate error status return from system on ms-dos?
How do you list files in a directory?
What are the 4 data types?
What is preprocessor with example?
Describe the modifier in c?
What is identifiers in c with examples?
What is clrscr ()?
Write the test cases for checking a variable having value in range -10.0 to +10.0?
Explain how are portions of a program disabled in demo versions?