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


Please Help Members By Posting Answers For Below Questions

Explain what are the standard predefined macros?

647


What is the difference between fread and fwrite function?

633


What is volatile keyword in c?

577


How to delete a node from linked list w/o using collectons?

2085


How is = symbol different from == symbol in c programming?

607






Explain what is the benefit of using an enum rather than a #define constant?

714


Explain what does it mean when a pointer is used in an if statement?

613


Why do we use return in c?

560


How can you increase the size of a dynamically allocated array?

636


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

2182


write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?

2405


What is the right way to use errno?

618


Difference between Shallow copy and Deep copy?

1564


Is fortran still used today?

597


How can I read/write structures from/to data files?

544