Binary number into decimal number and vice versa Program in C

Binary number into decimal number and vice versa Program in C
Binary number into decimal number and vice versa Program in C

WAP to convert binary number into decimal number and vice versa.

#include<stdio.h>
#include 
void main()
{
	int n,r,rev=0,p=0;
	printf("Enter binary number=");	
	scanf("%d",&n);
	while(n>0)
	{
		r=n%10;
		if(r!=0)
		{
			rev= rev+(int)pow(2,p);
		}	
		n=n/10;	
		p++;
	}
	printf("Decimal number=%d",rev);		
}

Output:

Enter binary number=1011
Decimal number=11
b. tech. bca c language tutorial learn c language study c language
Recent Posts