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

Explain the difference between call by value and call by reference in c language?

1105


Who invented b language?

1400


Why we use void main in c?

1159


In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)

2116


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

1272


What should malloc() do?

1164


What does it mean when the linker says that _end is undefined?

1085


why we wont use '&' sing in aceesing the string using scanf

2364


which is conditional construct a) if statement b) switch statement c) while/for d) goto

1215


What is the difference between ++a and a++?

1201


why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above

1070


What standard functions are available to manipulate strings?

1144


Why is python slower than c?

1075


What are linked lists in c?

1125


What is a pointer in c plus plus?

1296