diff options
| author | Connor McDowell <[email protected]> | 2024-01-29 19:04:13 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-01-29 19:04:13 -0800 |
| commit | 50812bf6b58531996adc9bd430ba2815c8066d79 (patch) | |
| tree | 882a7f88bb49ae10ba8a1cf7a483d035f6bcfb1c | |
| parent | project created, program.cpp, Loops.cpp, and Loops.h created (diff) | |
| download | in-class-exercise-7-connormcdowell275-50812bf6b58531996adc9bd430ba2815c8066d79.tar.xz in-class-exercise-7-connormcdowell275-50812bf6b58531996adc9bd430ba2815c8066d79.zip | |
post notes, all comits after include exercise proper
| -rw-r--r-- | Project1/program.cpp | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/Project1/program.cpp b/Project1/program.cpp index e69de29..30f7077 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -0,0 +1,127 @@ +// Name: Connor McDowell +// date: 1/29/2024 +// class: CIS116 +// Reason: inclass exercise 7 + +#include <iostream> +using std::cout; +using std::cin; +using std::endl; + +//notes +//loop types and examples + +//void ForLoopExamples(); +//void WhileLoopExamples(); +//void DoWhileLoopExamples(); + +int main() +{ + //ForLoopExamples(); + //WhileLoopExamples(); + //DoWhileLoopExamples(); + + + + + 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 |