fork download
  1.  
  2. #include <iostream>
  3. #include <math.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. float x, y, a=-2, b=2, h=0.2;
  9. //cout<<"Enter left and right limits (a and b) of the interval and step value (h) separated by space:\n";
  10. //cin>>a>>b>>h;
  11. cout.precision(3);
  12. cout<<"\n X | Y\n_________|_________\n";
  13. for (x=a; x<=b; x+=h)
  14. {
  15. if (x>0)
  16. {
  17. cout.width(8);
  18. cout<<x<<" | ";
  19. cout.width(8);
  20. cout<<pow(log(abs(x)), 2)/x<<"\n";
  21. }
  22. if (x<0)
  23. {
  24. cout.width(8);
  25. cout<<x<<" | ";
  26. cout.width(8);
  27. cout<<1/(pow(x, 2)*sin(2*x))<<"\n";
  28. }
  29. if (x==0)
  30. {
  31. y=0;
  32. cout.width(8);
  33. cout<<x<<" | ";
  34. cout.width(8);
  35. cout<<y<<"\n";
  36. }
  37. }
  38. system("pause");
  39. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:20:23: error: call of overloaded ‘abs(float&)’ is ambiguous
    cout<<pow(log(abs(x)), 2)/x<<"\n";
                       ^
prog.cpp:20:23: note: candidates are:
In file included from /usr/include/c++/4.8/cstdlib:72:0,
                 from /usr/include/c++/4.8/ext/string_conversions.h:41,
                 from /usr/include/c++/4.8/bits/basic_string.h:2815,
                 from /usr/include/c++/4.8/string:52,
                 from /usr/include/c++/4.8/bits/locale_classes.h:40,
                 from /usr/include/c++/4.8/bits/ios_base.h:41,
                 from /usr/include/c++/4.8/ios:42,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:2:
/usr/include/stdlib.h:770:12: note: int abs(int)
 extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
            ^
In file included from /usr/include/c++/4.8/ext/string_conversions.h:41:0,
                 from /usr/include/c++/4.8/bits/basic_string.h:2815,
                 from /usr/include/c++/4.8/string:52,
                 from /usr/include/c++/4.8/bits/locale_classes.h:40,
                 from /usr/include/c++/4.8/bits/ios_base.h:41,
                 from /usr/include/c++/4.8/ios:42,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:2:
/usr/include/c++/4.8/cstdlib:174:3: note: long long int std::abs(long long int)
   abs(long long __x) { return __builtin_llabs (__x); }
   ^
/usr/include/c++/4.8/cstdlib:166:3: note: long int std::abs(long int)
   abs(long __i) { return __builtin_labs(__i); }
   ^
stdout
Standard output is empty