Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 || operator and how does it function in a program?

1040


How can I copy just a portion of a string?

1271


Differentiate between the expression “++a” and “a++”?

1203


What is the best way of making my program efficient?

962


What is non linear data structure in c?

967


Is it better to use a macro or a function?

1099


Is null a keyword in c?

1138


Why can’t constant values be used to define an array’s initial size?

1325


What does the c preprocessor do?

1050


What is array of structure in c programming?

1240


What is difference between main and void main?

1117


Explain what is wrong with this program statement?

1069


List the different types of c tokens?

1010


What is #ifdef ? What is its application?

1054


Find MAXIMUM of three distinct integers using a single C statement

1013