janac

calculate square or triangle

Apr 9th, 2022 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. char go = 'y';
  7. int choice = 0;
  8.  
  9. while (go == 'y' || go == 'Y')
  10. {
  11. // do the tasks
  12.  
  13. cout << "Enter 1 to calculate the area of a square" << endl;
  14. cout << "Enter 2 to calculate the area of a triangle" << endl;
  15.  
  16. cin >> choice;
  17. if (choice == 1)
  18. {
  19. // calculate square
  20. cout << "Square" << endl;
  21. }
  22. else
  23. {
  24. // calculate triangle
  25. cout << "Triangle" << endl;
  26. }
  27.  
  28. cout << "Do you want to continue? (y or n)" << endl;
  29. cin >> go;
  30. }
  31.  
  32. return 0;
  33. }
Add Comment
Please, Sign In to add comment