fork download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4. using namespace std;
  5. void bitodec(int);
  6. int y =1;
  7. int u ;
  8. int main(void)
  9. {
  10. string input;
  11. cout << "Enter string of binary digits " ;
  12. cin >> input ;
  13. for_each(input.begin(), input.end(),bitodec);
  14. cout << "Decimal equivalent is " << u << endl;
  15. system("PAUSE");
  16. }
  17. void bitodec(int i)
  18. {
  19.  
  20.  
  21. if(i != 0)
  22. {
  23. int u = pow(2.0, (int)y);
  24. u = u +u ;
  25. }
  26. else
  27. {
  28. ;
  29. }
  30. y++;
  31.  
  32.  
  33. }
  34.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:13:48: error: ‘for_each’ was not declared in this scope
     for_each(input.begin(), input.end(),bitodec);
                                                ^
stdout
Standard output is empty