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

What are the data types present in c?

623


Why doesnt the call scanf work?

665


Explain is it valid to address one element beyond the end of an array?

729


What is strcpy() function?

652


What is a string?

664






How can I change their mode to binary?

692


what are enumerations in C

720


In a switch statement, what will happen if a break statement is omitted?

599


Why is c called a structured programming language?

673


Why c is faster than c++?

627


What is the purpose of 'register' keyword in c language?

625


How important is structure in life?

586


explain what is fifo?

630


Describe the difference between = and == symbols in c programming?

773


Can 'this' pointer by used in the constructor?

608