more_and.cpp 713 B

12345678910111213141516171819202122232425262728293031
  1. // more_and.cpp -- using the logical AND operator
  2. #include <iostream>
  3. const char * qualify[4] = // an array of pointers*/
  4. { // to strings
  5. "10,000-meter race.\n",
  6. "mud tug-of-war.\n",
  7. "masters canoe jousting.\n",
  8. "pie-throwing festival.\n"
  9. };
  10. int main()
  11. {
  12. using namespace std;
  13. int age;
  14. cout << "Enter your age in years: ";
  15. cin >> age;
  16. int index;
  17. if (age > 17 && age < 35)
  18. index = 0;
  19. else if (age >= 35 && age < 50)
  20. index = 1;
  21. else if (age >= 50 && age < 65)
  22. index = 2;
  23. else
  24. index = 3;
  25. cout << "You qualify for the " << qualify[index];
  26. // cin.get();
  27. // cin.get();
  28. return 0;
  29. }