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
Explain what are the standard predefined macros?
What is the difference between fread and fwrite function?
What is volatile keyword in c?
How to delete a node from linked list w/o using collectons?
How is = symbol different from == symbol in c programming?
Explain what is the benefit of using an enum rather than a #define constant?
Explain what does it mean when a pointer is used in an if statement?
Why do we use return in c?
How can you increase the size of a dynamically allocated array?
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?
What is the right way to use errno?
Difference between Shallow copy and Deep copy?
Is fortran still used today?
How can I read/write structures from/to data files?