aboutsummaryrefslogtreecommitdiff
path: root/project/NestedLoops.cpp
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-02-02 11:36:08 -0800
committerConnor McDowell <[email protected]>2024-02-02 11:36:08 -0800
commit567be58fb254052277f5738c599fc254ea8ccab1 (patch)
treeb4f21c859032da10025794b9f8016b04ba0b0f1c /project/NestedLoops.cpp
parentframework set up for all files (diff)
downloadin-class-exercise-8-connormcdowell275-567be58fb254052277f5738c599fc254ea8ccab1.tar.xz
in-class-exercise-8-connormcdowell275-567be58fb254052277f5738c599fc254ea8ccab1.zip
nested loop created
Diffstat (limited to 'project/NestedLoops.cpp')
-rw-r--r--project/NestedLoops.cpp54
1 files changed, 53 insertions, 1 deletions
diff --git a/project/NestedLoops.cpp b/project/NestedLoops.cpp
index e451ce2..fdb59e2 100644
--- a/project/NestedLoops.cpp
+++ b/project/NestedLoops.cpp
@@ -1,3 +1,55 @@
#include "NestedLoops.h"
-#include <iostream> \ No newline at end of file
+#include <iostream>
+
+using std::cout;
+using std::cin;
+using std::endl;
+
+void NestedForLoop(size_t n, size_t m)
+{
+ for (int i = 0; i < n; ++i)
+ {
+ for (int j = 0; j < m; ++j)
+ {
+ cout << "i = " << i << ", j = " << j << endl;
+ cout << i * j << endl;
+
+ }
+ }
+}
+
+
+void NestedWhileLoop(size_t n, size_t m)
+{
+ n = 0;
+ while (n < 4)
+ {
+ m = 0;
+ while (m < 3)
+ {
+ cout << "n = " << n << ", m = " << m << endl;
+ m++;
+ }
+ cout << endl;
+ n++;
+ }
+}
+
+
+void NestedDoWhileLoop(size_t n, size_t m)
+{
+ n = 1;
+ do
+ {
+ m = 1;
+ do
+ {
+ cout << n * m << " ";
+ ++m;
+
+ } while (m <= 3);
+ cout << endl;
+ n++;
+ } while (n <=3 );
+}