Chapter17ex1.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. main()
  4. {
  5. int choice;
  6. printf("What do you want to do?\n");
  7. printf("1. Add New Contact\n");
  8. printf("2. Edit Existing Contact\n");
  9. printf("3. Call Contact\n");
  10. printf("4. Text Contact\n");
  11. printf("5. Exit\n");
  12. do
  13. {
  14. printf("Enter your choice: ");
  15. scanf(" %d", &choice);
  16. switch (choice)
  17. {
  18. case (1): printf("\nTo add you will need the ");
  19. printf("contact's\n");
  20. printf("First name, last name, and number.\n");
  21. break;
  22. case (2): printf("\nGet ready to enter the name of ");
  23. printf("name of the\n");
  24. printf("contact you wish to change.\n");
  25. break;
  26. case (3): printf("\nWhich contact do you ");
  27. printf("wish to call?\n");
  28. break;
  29. case (4): printf("\nWhich contact do you ");
  30. printf("wish to text?\n");
  31. break;
  32. case (5): exit(1); //Exits the program early
  33. default: printf("\n%d is not a valid choice.\n", choice);
  34. printf("Try again.\n");
  35. break;
  36. }
  37. } while ((choice < 1) || (choice > 5));
  38. return 0;
  39. }