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 a lookup table in c?

1175


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

1076


What is volatile variable how do you declare it?

1188


I need previous papers of CSC.......plz help out by posting them.......

2352


What is string function in c?

1052


Can you write a programmer for FACTORIAL using recursion?

1101


Explain the bubble sort algorithm.

1113


What does node * mean?

1308


Is register a keyword in c?

1088


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2490


What is a dynamic array in c?

1226


What is structure and union in c?

1208


Write a code on reverse string and its complexity.

1095


Do you know what are the properties of union in c?

1131


How can I trap or ignore keyboard interrupts like control-c?

1117