Over a million developers have joined DZone.

Binary To Decimal In C

·
program to convert binary number to decimal 


#include 
#include 
main()
{
	int bin,rem,n=0,sum=0;
	printf("please enter binary number");
	scanf("%d",&bin);
	while(bin)
	{
		rem=bin%10;
		sum=sum+(rem*pow(2,n));
		bin=bin/10;
		n++;
	}
	printf("%d\n",sum);	
}
/*
by joseph dias 
email josephdias92@gmail.com
*/

Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}