/* C Program To Convert Binary Number Into Decimal Number */ #include<stdio.h> #include<conio.h> #include<math.h> int main() { int n,decimal=0, i=0, rem,m; printf("Enter a binary number:\n"); scanf("%d", &n); m=n; while (n!=0) { rem = n%10; n/=10; decimal += rem*pow(2,i); ++i; } printf("Decimal equivalent of %d is: %d", m, decimal); return 0; }
Enter a binary number: 100101 Decimal equivalent of 100101 is: 37
No comments:
Post a Comment