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 / saravana priya

#include <stdio.h>

void main()
{
int num, bnum, dec = 0, base = 1, rem ;

printf(“Enter a binary number(1s and 0s)\n”);
scanf(“%d”, &num); /*maximum five digits */

bnum = num;

while( num > 0)
{
rem = num % 10;
dec = dec + rem * base;
num = num / 10 ;
base = base * 2;
}

printf(“The Binary number is = %d\n”, bnum);
printf(“Its decimal equivalent is =%d\n”, dec);

} /* End of main() */

Is This Answer Correct ?    25 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between text files and binary files?

1283


What are the advantages and disadvantages of a heap?

1147


the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset

1050


What does s c mean in text?

1054


what are the 10 different models of writing an addition program in C language?

1841


How can I convert a number to a string?

1095


How can I write functions that take a variable number of arguments?

1076


Is it better to bitshift a value than to multiply by 2?

1050


How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

975


I need a sort of an approximate strcmp routine?

987


Why we use stdio h in c?

983


Write a program to check prime number in c programming?

1029


What is static memory allocation?

1099


How can I get random integers in a certain range?

1016


Explain what is the most efficient way to store flag values?

1173