From a6a86fd67296838761e81b7a8c4e2cb0e6dcd6f7 Mon Sep 17 00:00:00 2001 From: Connor McDowell Date: Tue, 30 Jan 2024 12:11:00 -0800 Subject: all loops created, header called, both .cpps working as expected --- Project1/program.cpp | 115 ++++----------------------------------------------- 1 file changed, 8 insertions(+), 107 deletions(-) (limited to 'Project1/program.cpp') 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 +#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 -- cgit v1.2.3