diff options
| author | WiserJ <[email protected]> | 2021-10-19 15:08:01 -0700 |
|---|---|---|
| committer | WiserJ <[email protected]> | 2021-10-19 15:08:01 -0700 |
| commit | 6a393ffd5c851b32276674e3db99c880ba1b367d (patch) | |
| tree | d915639ccf1b1aad022f192a009257fb44835ed9 | |
| parent | p.177 (diff) | |
| download | cst116-lab3-jeffwoit-6a393ffd5c851b32276674e3db99c880ba1b367d.tar.xz cst116-lab3-jeffwoit-6a393ffd5c851b32276674e3db99c880ba1b367d.zip | |
p.177
| -rw-r--r-- | CST116F2021-Lab3/CST116F2021-Lab3.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/CST116F2021-Lab3/CST116F2021-Lab3.cpp b/CST116F2021-Lab3/CST116F2021-Lab3.cpp index c5a7f67..df75723 100644 --- a/CST116F2021-Lab3/CST116F2021-Lab3.cpp +++ b/CST116F2021-Lab3/CST116F2021-Lab3.cpp @@ -7,7 +7,7 @@ using namespace std; int main() { - //p.177 8.2 + //p.179 int input = 0; int remainder = 0; @@ -15,6 +15,40 @@ int main() cout << "Please enter an integer between 1 and 50: "; cin >> input; + do + cout << "User input invalid. Please enter an integer between 1 and 50: "; + while (input < 1 || input > 50); + + remainder = input % 2; + + while (remainder != 0) + { + input = input--; + remainder = input % 2; + } + + while (input != 0) + { + cout << input << ' '; + input = input - 2; + } + + cout << "0."; + + return 0; + + + + + + //p.177 8.2 + + /* int input = 0; + int remainder = 0; + + cout << "Please enter an integer between 1 and 50: "; + cin >> input; + if (input < 1 || input > 50) { cout << "User input invalid. Exiting program."; @@ -37,7 +71,7 @@ int main() cout << "0."; - return 0; + return 0;*/ |