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 is stack in c?

624


What does 4d mean in c?

963


Is c procedural or functional?

595


Is c# a good language?

618


how we can make 3d venturing graphics on outer interface

4030






What is the symbol indicated the c-preprocessor?

709


What is void main () in c?

752


What are the uses of null pointers?

607


Define recursion in c.

711


What are the different categories of functions in c?

664


How will you find a duplicate number in a array without negating the nos ?

1660


Are comments included during the compilation stage and placed in the EXE file as well?

682


Why do we use namespace feature?

591


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

643


How can I change the size of the dynamically allocated array?

640