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 || operator and how does it function in a program?
How can I copy just a portion of a string?
Differentiate between the expression “++a” and “a++”?
What is the best way of making my program efficient?
What is non linear data structure in c?
Is it better to use a macro or a function?
Is null a keyword in c?
Why can’t constant values be used to define an array’s initial size?
What does the c preprocessor do?
What is array of structure in c programming?
What is difference between main and void main?
Explain what is wrong with this program statement?
List the different types of c tokens?
What is #ifdef ? What is its application?
Find MAXIMUM of three distinct integers using a single C statement