// This program is to show the basics of the cmath library // // Written by: Pat Troy // For: CS 107 // Date: 1/27/2203 /************************************************************* * This program is to show the basics of the cmath library * * * * Written by: Pat Troy * * For: CS 107 * * Date: 1/27/2203 * *************************************************************/ #include #include using namespace std; main() { float val1 = 1, val2 =2, val3(3); float val4, val5; cout << "Welcome" << endl << endl; // prompt for and get the first value cout << "Enter in a value: "; cin >> val1; cout << "The value entered was: " << val1 << endl << endl; // Use the square root function from the cmath library if (val1 >= 0) cout << "Statement 1" << endl; cout << "Statement 2" << endl; cout << "Statement 3" << endl; cout << "Statement 4" << endl; cout << "Statement 5" << endl; cout << endl; if (val1 >= 0) { cout << "Statement 1a" << endl; cout << "Statement 2a" << endl; cout << "Statement 3a" << endl; cout << "Statement 4a" << endl; cout << "Statement 5a" << endl; } cout << endl; if (val1 >= 0) { cout << "Statement 1b" << endl; cout << "Statement 2b" << endl; } else { cout << "Statement 3b" << endl; cout << "Statement 4b" << endl; } cout << endl; if (val1 >= 0) { cout << "Statement 1c" << endl; cout << "Statement 2c" << endl; } if (val1 >= 5) { cout << "Statement 3c" << endl; cout << "Statement 4c" << endl; } cout << endl; if (val1 >= 0) { cout << "Statement 1d" << endl; cout << "Statement 2d" << endl; } else if (val1 >= 5) { cout << "Statement 3d" << endl; cout << "Statement 4d" << endl; } else { cout << "Statement 5d" << endl; cout << "Statement 6d" << endl; } if (val1 >= 5) { cout << "Statement 3e" << endl; cout << "Statement 4e" << endl; } else if (val1 >= 0) { cout << "Statement 1e" << endl; cout << "Statement 2e" << endl; } else { cout << "Statement 5e" << endl; cout << "Statement 6e" << endl; } cout << endl; if ((val1 >= 0) && (val1 < 5)) { cout << "Statement 1f" << endl; cout << "Statement 2f" << endl; } else if (val1 >= 5) { cout << "Statement 3f" << endl; cout << "Statement 4f" << endl; } else { cout << "Statement 5f" << endl; cout << "Statement 6f" << endl; } cout << endl << "Goodbye" << endl; }