google-site-verification: googlef8aa845b858144d3.html COMPUTER SCIENCE NOTES: CONVERSION OF BINARY TO DECIMAL

Monday, July 17, 2017

CONVERSION OF BINARY TO DECIMAL

/*convert binary to decimal */
#include<stdio.h>
#include<conio.h>
void main()
{
int j=1,dec=0,d,n,rem;
clrscr();
printf("Enter a binary number :");
scanf("%d",&n);
while(n>0)
{
rem=n%10;
d=rem*j;
dec+=d;
j*=2;
n/=10;
}
printf("decimal number is = %d",dec);
getch();
}

No comments:

Post a Comment