and.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // and.cpp -- using the logical AND operator
  2. #include <iostream>
  3. const int ArSize = 6;
  4. int main()
  5. {
  6. using namespace std;
  7. float naaq[ArSize];
  8. cout << "Enter the NAAQs (New Age Awareness Quotients) "
  9. << "of\nyour neighbors. Program terminates "
  10. << "when you make\n" << ArSize << " entries "
  11. << "or enter a negative value.\n";
  12. int i = 0;
  13. float temp;
  14. cout << "First value: ";
  15. cin >> temp;
  16. while (i < ArSize && temp >= 0) // 2 quitting criteria
  17. {
  18. naaq[i] = temp;
  19. ++i;
  20. if (i < ArSize) // room left in the array,
  21. {
  22. cout << "Next value: ";
  23. cin >> temp; // so get next value
  24. }
  25. }
  26. if (i == 0)
  27. cout << "No data--bye\n";
  28. else
  29. {
  30. cout << "Enter your NAAQ: ";
  31. float you;
  32. cin >> you;
  33. int count = 0;
  34. for (int j = 0; j < i; j++)
  35. if (naaq[j] > you)
  36. ++count;
  37. cout << count;
  38. cout << " of your neighbors have greater awareness of\n"
  39. << "the New Age than you do.\n";
  40. }
  41. // cin.get();
  42. // cin.get();
  43. return 0;
  44. }