/* five-six-props-eof.cpp written by: Kevin Corcoran CIS 122 This program takes an integer as input and computes the input's divisibility by 5 and 6. Output is then displayed, and the user is prompted to enter more input. Program termination occurs upon a end-of-file character being received through input. */ #include using namespace std; int main(){ // User input int i; // Variables representing divisibility of user input bool and, or, notBoth; // Prompt user for input cout << "Enter an integer (ctrl-z, Enter to exit):"; cin >> i; //check the 5-6 properties of entered value while(cin){ i = i + 1; // Compute divisibility of input and = (i%5 == 0) || (i/6 == 0); or = (i%5 == 0) && (i/6 == 0); if(and) notBoth = true; else notBoth = or; // Print true and false instead of 1 and 0 cout << boolalpha; // Output our computed values cout << "Is " << i << " divisible by 5 and 6? " << and << endl << "Is " << i << " divisible by 5 or 6? " << or << endl << "Is " << i << " divisible by 5 or 6, but not both? " << notBoth << endl; // Prompt the user for more input cout << "\nEnter an integer (ctrl-z, Enter to exit):"; cin >> i; } // EOF character read - exit! cout << endl << "exiting..." << endl; return 0; }