aboutsummaryrefslogtreecommitdiff
path: root/In Class Exercise 8
diff options
context:
space:
mode:
authorMiles-Cell <[email protected]>2024-02-01 16:28:14 -0800
committerMiles-Cell <[email protected]>2024-02-01 16:29:25 -0800
commit1193083f5e7543ac5536533b7757d30fb00ef4c9 (patch)
tree1f7c1ce9e8c5ee7bb9b790ba25eecabeca17bcc8 /In Class Exercise 8
parentAdded all new files. program.cpp, NestedLoops.cpp, NestedLoop.h (diff)
downloadin-class-exercise-8-miles-cell-1193083f5e7543ac5536533b7757d30fb00ef4c9.tar.xz
in-class-exercise-8-miles-cell-1193083f5e7543ac5536533b7757d30fb00ef4c9.zip
Exercise completed!!
Diffstat (limited to 'In Class Exercise 8')
-rw-r--r--In Class Exercise 8/In Class Exercise 8/NestedLoops.cpp26
-rw-r--r--In Class Exercise 8/In Class Exercise 8/NestedLoops.h6
-rw-r--r--In Class Exercise 8/In Class Exercise 8/program.cpp50
3 files changed, 61 insertions, 21 deletions
diff --git a/In Class Exercise 8/In Class Exercise 8/NestedLoops.cpp b/In Class Exercise 8/In Class Exercise 8/NestedLoops.cpp
index 335ffa2..64fc96d 100644
--- a/In Class Exercise 8/In Class Exercise 8/NestedLoops.cpp
+++ b/In Class Exercise 8/In Class Exercise 8/NestedLoops.cpp
@@ -1,28 +1,20 @@
-// Name: Miles Ellsworth
-// Date: 1/31/2024
-// Class: CST 116
-// Assignment: In Class Exercise 7
-
-
#include <iostream>
#include "NestedLoops.h"
+void NestedForLoop(size_t n, size_t m)
+{
-void ForLoop(size_t n);
-void WhileLoop(size_t n);
-
-using std::cout;
-using std::cin;
-using std::endl;
+}
+void NestedWhileLoop(size_t n, size_t m)
+{
+}
-int main()
+void NestedDoWhileLoop(size_t n, size_t m)
{
- ForLoop();
- WhileLoop();
-
- return 0;
}
+
+// NOTE: As instructed in class. Not sure why it's not all working together. \ No newline at end of file
diff --git a/In Class Exercise 8/In Class Exercise 8/NestedLoops.h b/In Class Exercise 8/In Class Exercise 8/NestedLoops.h
index c51839e..f256cd3 100644
--- a/In Class Exercise 8/In Class Exercise 8/NestedLoops.h
+++ b/In Class Exercise 8/In Class Exercise 8/NestedLoops.h
@@ -1,9 +1,11 @@
#ifndef LOOPS_H
#define LOOPS_H
-void ForLoop(size_t n);
-void WhileLoop(size_t n);
+void NestedForLoop(size_t n, size_t m);
+void NestedWhileLoop(size_t n, size_t m);
+
+void NestedDoWhileLoop(size_t n, size_t m);
#endif // !LOOPS_H
diff --git a/In Class Exercise 8/In Class Exercise 8/program.cpp b/In Class Exercise 8/In Class Exercise 8/program.cpp
index f6d446a..bb93475 100644
--- a/In Class Exercise 8/In Class Exercise 8/program.cpp
+++ b/In Class Exercise 8/In Class Exercise 8/program.cpp
@@ -1,7 +1,7 @@
// Name: Miles Ellsworth
// Date: 1/31/2024
// Class: CST 116
-// Assignment: In Class Exercise 7
+// Assignment: In Class Exercise 8
#include <iostream>
@@ -11,15 +11,61 @@ using std::cout;
using std::cin;
using std::endl;
+void NestedForLoop();
+void NestedWhileLoop();
+void NestedDoWhileLoop();
int main()
{
+ //NestedForLoop();
+ //NestedWhileLoop();
+ //NestedDoWhileLoop();
+ NestedForLoop(0, 20);
+ NestedWhileLoop(0, 50);
+ NestedDoWhileLoop(0, 100);
+ return 0;
+}
+void NestedForLoop(size_t n, size_t m)
+{
+ for (size_t i = 0; i < n; ++i)
+ {
+ for (size_t j = 0; j < m; ++j)
+ {
+ cout << i * j << endl;
+ }
+ }
+}
- return 0;
+void NestedWhileLoop(size_t n, size_t m)
+{
+ size_t i = 0;
+ while (i < n)
+ {
+ size_t j = 0;
+ while (j < m)
+ {
+ cout << i * j << endl;
+ ++j;
+ }
+ ++i;
+ }
+}
+
+void NestedDoWhileLoop(size_t n, size_t m)
+{
+ size_t i = 0;
+ do {
+ size_t j = 0;
+ do {
+ cout << i * j << endl;
+ ++j;
+ } while (j < m);
+ ++i;
+ } while (i < n);
}