WAP in C to Convert the Binary Number into Decimal Number ?

#include <stdio.h>
#include<conio.h>
void main()
{
int num, binary, decimal = 0, base = 1, rem;
clrscr();
printf(“Enter a binary number(1s and 0s) \n”);
scanf(“%d”, &num); /* maximum five digits due to range of integer */
binary = num;
while (num > 0)
{
rem = num % 10;
decimal = decimal + rem * base;
num = num / 10 ;
base = base * 2;
}
printf(“The Binary number is = %d \n”, binary);
printf(“Decimal equivalent is = %d \n”, decimal);
getch();
}

Output :-

BinToDec

Advertisements

3 thoughts on “WAP in C to Convert the Binary Number into Decimal Number ?

  1. I do believe all the ideas you’ve introduced to your post. They are very convincing and will certainly work. Still, the posts are very short for beginners. May just you please lengthen them a bit from next time? Thanks for the post.

    Like

  2. You could definitely see your enthusiasm in the work you write. The sector hopes for more passionate writers like you who aren’t afraid to say how they believe. All the time follow your heart.

    Like

  3. Wonderful web site. Lots of helpful info here. I am sending it to several friends ans also sharing in delicious. And obviously, thanks in your effort!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s