how to convert binary to decimal and decimal to binary in C
lanaguage
Answer Posted / sheela
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int n,r,s=0,i=0;
printf("\nEnter the binary number ");
scanf("%d",&n);
while(n>0)
{
r=n%10;
n=n/10;
s=s+r*pow(2,i++);
}
printf("\nThe binary equivalent is ");
printf("%d",s);
getch();
}
| Is This Answer Correct ? | 10 Yes | 2 No |
Post New Answer View All Answers
What is the function of volatile in c language?
Is a house a mass structure?
What does double pointer mean in c?
What is the difference between Printf(..) and sprint(...) ?
Why clrscr is used after variable declaration?
1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.
Differentiate between declaring a variable and defining a variable?
How important is structure in life?
What is the explanation for modular programming?
What are the different properties of variable number of arguments?
Explain what is wrong with this program statement? Void = 10;
what will be maximum number of comparisons when number of elements are given?
What is a constant and types of constants in c?
What does d mean?
Which one would you prefer - a macro or a function?