diff options
Diffstat (limited to 'CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp')
| -rw-r--r-- | CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp b/CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp index 1074279..10aa010 100644 --- a/CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp +++ b/CST116F2021-Lab3/CST116F2021-Lab3-Guertin.cpp @@ -302,4 +302,51 @@ int main() 1. +#include <iostream> +#include<iomanip> +#include <stdlib.h> +#include <thread> +#include <string> +using std::cout; +using std::endl; +using std::string; + +int main() +{ + int count; + int converted_to_even; + + + cout << "Input any number between 1 and 50:\n\n"; + std::cin >> count; + + + if (count >= 1 && count <= 50) + { + cout << "\n\nCounting down the even numbers to 0:\n\n"; + } + else + do { + cout << "\n\nERROR, this number is not between 1 and 50, please enter a number between 1 and 50\n\n"; + std::cin >> count; + } + + while (count > 50 || count < 1); + + + if (count % 2 == 1) + { + converted_to_even = count - 1; + } + else + { + converted_to_even = count; + } + + while (converted_to_even >= 0) + { + cout << converted_to_even << endl; + converted_to_even -= 2; + } +} |