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 are the data types present in c?
Why doesnt the call scanf work?
Explain is it valid to address one element beyond the end of an array?
What is strcpy() function?
What is a string?
How can I change their mode to binary?
what are enumerations in C
In a switch statement, what will happen if a break statement is omitted?
Why is c called a structured programming language?
Why c is faster than c++?
What is the purpose of 'register' keyword in c language?
How important is structure in life?
explain what is fifo?
Describe the difference between = and == symbols in c programming?
Can 'this' pointer by used in the constructor?