fork download
  1.  
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5. int square (int l, int w);
  6. double triangle (double h, double b);
  7. double circle (double r);
  8. int main()
  9. {
  10.  
  11. double height ,base ,radius , triangle_area , circle_area ;
  12. int length, width;
  13. string a;
  14. do {
  15. cout<<" Hello, I will help you with common math formulas ";
  16. cout << "1.square.";
  17. cout << "2.triangles.";
  18. cout << "3.circle";
  19. cout << ">> ";
  20. int choice;
  21. cin >> choice;
  22.  
  23.  
  24. switch(choice){
  25. case 1:
  26. cout << "Enter the length of the square: ";
  27. cin >> length;
  28. cout << "Enter the width of the square: ";
  29. cin >> width;
  30. int area;
  31. area= square(length, width);
  32. cout << "The area of the square is " << area << endl;
  33.  
  34. break;
  35. case 2:
  36. cout << "Enter the height of the triangle: ";
  37. cin >> height ;
  38. cout << "Enter the base of the triangle: ";
  39. cin >> base ;
  40. triangle_area = triangle(height, base);
  41. cout << "The area of the triangle is " << triangle_area << endl;
  42.  
  43. break;
  44. case 3:
  45. cout << "Enter the circle: ";
  46. cin >> radius;
  47. circle_area = circle (radius);
  48. cout << "The area of the circle is " << circle_area << endl;
  49. break;
  50.  
  51. default:
  52. cout << "Wrong choice, you have to enter a number between 1 and 3" << endl;
  53. break;
  54.  
  55. cout << "Would you like to exit? (yes/no): ";
  56. cin >> a;
  57. }
  58. while ((a == "no") || (a == "n"));
  59. return 0;
  60. }
  61. }
  62.  
  63. int square (int l, int w)
  64. {
  65. return l * w;
  66. }
  67. double triangle (double h, double b)
  68. {
  69. return h * b* 0.5;
  70. }
  71. double circle (double r)
  72. {
  73. return 3.14159 * (r * r);
  74. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:61:1: error: expected ‘while’ before ‘}’ token
 }
 ^
prog.cpp:61:1: error: expected ‘(’ before ‘}’ token
prog.cpp:61:1: error: expected primary-expression before ‘}’ token
prog.cpp:61:1: error: expected ‘)’ before ‘}’ token
prog.cpp:61:1: error: expected ‘;’ before ‘}’ token
stdout
Standard output is empty