fork download
  1. #include<stdlib.h>
  2. #include<stdio.h>
  3. #include<math.h>
  4.  
  5. int main()
  6. {
  7. int bin, dec = 0, i;
  8. printf("\nEnter A Binary Number: \t");
  9. scanf("%d", &bin);
  10. for(i = 0; bin > 0; i++)
  11. {
  12. dec = dec + pow(2, i) * (bin % 10);
  13. bin = bin / 10;
  14. }
  15. printf("\nDecimal Equivalent of Binary Number: \t %d\n", dec);
  16. return 0;
  17. }
Success #stdin #stdout 0s 5284KB
stdin
0001
stdout
Enter A Binary Number: 	
Decimal Equivalent of Binary Number: 	 1