fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int choice;
  5.  
  6.  
  7. printf("Select an operation:\n");
  8. printf("1. Add\n2. Subtract\n3. Multiply\n4. Divide\n5. Exit\n");
  9. printf("Enter your choice (1-5): ");
  10. scanf("%d", &choice);
  11.  
  12. switch (choice) {
  13. case 1:
  14. printf("You selected Add.\n");
  15. break;
  16. case 2:
  17. printf("You selected Subtract.\n");
  18. break;
  19. case 3:
  20. printf("You selected Multiply.\n");
  21. break;
  22. case 4:
  23. printf("You selected Divide.\n");
  24. break;
  25. case 5:
  26. printf("Exiting program.\n");
  27. break;
  28. default:
  29. printf("Invalid choice! Please enter a number between 1 and 5.\n");
  30. }
  31.  
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 5276KB
stdin
3
stdout
Select an operation:
1. Add
2. Subtract
3. Multiply
4. Divide
5. Exit
Enter your choice (1-5): You selected Multiply.