diff options
| author | Yana Blashchishina <[email protected]> | 2024-02-01 21:01:17 -0800 |
|---|---|---|
| committer | Yana Blashchishina <[email protected]> | 2024-02-01 21:01:17 -0800 |
| commit | 90640e5471802a5ac13b7912d4996e58b235d552 (patch) | |
| tree | fcfa4f24fd348b2a4badca4c00739bb62cdfe81d /InClassExxercise7 | |
| parent | header done (diff) | |
| download | in-class-exercise-7-yanablash-90640e5471802a5ac13b7912d4996e58b235d552.tar.xz in-class-exercise-7-yanablash-90640e5471802a5ac13b7912d4996e58b235d552.zip | |
Diffstat (limited to 'InClassExxercise7')
| -rw-r--r-- | InClassExxercise7/InClassExxercise7/Loops.cpp | 30 | ||||
| -rw-r--r-- | InClassExxercise7/InClassExxercise7/program.cpp | 28 |
2 files changed, 57 insertions, 1 deletions
diff --git a/InClassExxercise7/InClassExxercise7/Loops.cpp b/InClassExxercise7/InClassExxercise7/Loops.cpp index e69de29..a513137 100644 --- a/InClassExxercise7/InClassExxercise7/Loops.cpp +++ b/InClassExxercise7/InClassExxercise7/Loops.cpp @@ -0,0 +1,30 @@ +#include "Loops.h" +#include <iostream> + +using std::cout; + + + +void ForLoop(size_t n) { + for (size_t i = 0;i <= n; ++i) { + cout << i << " "; + } + +} + +void WhileLoop(size_t n) { + size_t i = 0; + while (i <= n) { + cout << i << " "; + ++i; + } +} + + +void DoWhileLoop(size_t n) { + size_t i = 0; + do { + cout << i << " "; + ++i; + } while (i <= n); +}
\ No newline at end of file diff --git a/InClassExxercise7/InClassExxercise7/program.cpp b/InClassExxercise7/InClassExxercise7/program.cpp index 2652b6d..fbbfc30 100644 --- a/InClassExxercise7/InClassExxercise7/program.cpp +++ b/InClassExxercise7/InClassExxercise7/program.cpp @@ -3,4 +3,30 @@ // Class:CST116 // Assignment: In Class Exercise 7 -#include <iostream>
\ No newline at end of file + +#include "Loops.h" +#include <iostream> + + +using std::cout; + + +int main() { + + size_t n = 10; + + cout << "For Loop: "; + ForLoop(n); + + cout << "While Loop: "; + WhileLoop(n); + + cout << "Do While Loop: "; + DoWhileLoop(n); + + + + + + return 0; +}
\ No newline at end of file |