diff options
| author | Connor McDowell <[email protected]> | 2024-01-30 12:11:00 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-01-30 12:11:00 -0800 |
| commit | a6a86fd67296838761e81b7a8c4e2cb0e6dcd6f7 (patch) | |
| tree | e7fa6068de1301c48d0da45aed88b9b15b7d21cb /Project1/program.cpp | |
| parent | post notes, all comits after include exercise proper (diff) | |
| download | in-class-exercise-7-connormcdowell275-a6a86fd67296838761e81b7a8c4e2cb0e6dcd6f7.tar.xz in-class-exercise-7-connormcdowell275-a6a86fd67296838761e81b7a8c4e2cb0e6dcd6f7.zip | |
Diffstat (limited to 'Project1/program.cpp')
| -rw-r--r-- | Project1/program.cpp | 115 |
1 files changed, 8 insertions, 107 deletions
diff --git a/Project1/program.cpp b/Project1/program.cpp index 30f7077..1202f4c 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -4,6 +4,8 @@ // Reason: inclass exercise 7 #include <iostream> +#include "Loops.h" + using std::cout; using std::cin; using std::endl; @@ -11,117 +13,16 @@ using std::endl; //notes //loop types and examples -//void ForLoopExamples(); -//void WhileLoopExamples(); -//void DoWhileLoopExamples(); - int main() { - //ForLoopExamples(); - //WhileLoopExamples(); - //DoWhileLoopExamples(); - - - + int n = 0; + cout << "Please enter a whole number: "; + cin >> n; + ForLoop(n); + WhileLoop(n); + DoWhileLoop(n); return 0; } -void DoWhileLoopExamples() -{ - /*int i = 0; - do - { - cout << i << " "; - - ++i; - - } while (i < 10);*/ - - /*int countdown = 10; - do - { - cout << "Countdown: " << countdown << endl; - countdown--; - } while (countdown > 0);*/ - - /*int num; - do - { - cout << "enter a number (0 to exit): "; - cin >> num; - cout << "you entered: " << num << endl; - - } while (num != 0);*\ - - -} - - - -void WhileLoopExamples() -{ - // decare counter first - /*int i = 0; - while (i < 100) - { - std::cout << i << " "; - ++i; - }*/ - - // infinite loop because true is always true - // reinitialize variables every time - /*int i = 0; - while (i < 10 && i !=5) - { - std::cout << i << " "; - - ++i; - }*/ - - /*int j = 10; - int i = 0; - while (i < 5 && j > 5) - { - cout << i << "," << j << endl; - ++i; - j--; - }*/ - -} -void ForLoopExamples() -{ - //for (int i = 0; i < 10; ++i) - //{ - // std::cout << i << " "; - //} - - //for (int i = 10; i > 0; --i); - //{ - // std::cout << i << " "; - //} - - //int i, k, j, m, n; - - //for (auto i = 0; j = 5; i < 5; ++i; --j) - //{ - // std::cout << i << " " << j << std::endl; - // - //} - - /*for (int i = 0; i < 10 && i != 5; ++i) - { - std::cout << i << " "; - - }*/ - - /*for(auto i = 0, j = 4; (i < 100) || (j > 0); ++i, --j) - { - std::cout << i << " " << j << std::endl; - }*/ - - - - -}
\ No newline at end of file |