fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. int x;
  8. cout << "Enter the value of x: ";
  9. cin >> x;
  10.  
  11. switch (x) {
  12. case 6: {
  13. double a = 2;
  14. double b = 3;
  15. double result1 = a * x + b * x * x;
  16. cout << "For x = 6, ax + bx*x = " << result1 << endl;
  17. break;
  18. }
  19. case 2: {
  20. double e = exp(1);
  21. double result2 = e + x * x;
  22. cout << "For x = 2, e + x*x = " << result2 << endl;
  23. break;
  24. }
  25. case 7: {
  26. double b = 1;
  27. double result3 = sin(2 * b * x);
  28. cout << "For x = 7, sin(2 * b * x) = " << result3 << endl;
  29. break;
  30. }
  31. default:
  32. cout << "No operation defined for this value of x." << endl;
  33. }
  34.  
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 5276KB
stdin
5
stdout
Enter the value of x: No operation defined for this value of x.