aboutsummaryrefslogtreecommitdiff
path: root/project/NestedLoops.cpp
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-03-10 15:59:17 -0700
committerConnor McDowell <[email protected]>2024-03-10 15:59:17 -0700
commit5199c89accdc0d00a84160e75ac67f5f88e0add3 (patch)
treef312c5ccdbd5bccc14df5275ab3d86ccee8f7dd7 /project/NestedLoops.cpp
parentnested loop created (diff)
downloadin-class-exercise-8-connormcdowell275-5199c89accdc0d00a84160e75ac67f5f88e0add3.tar.xz
in-class-exercise-8-connormcdowell275-5199c89accdc0d00a84160e75ac67f5f88e0add3.zip
functions fixed, loop the proper amount of times, are labled, and done overwrite parameters.HEADmain
Diffstat (limited to 'project/NestedLoops.cpp')
-rw-r--r--project/NestedLoops.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/project/NestedLoops.cpp b/project/NestedLoops.cpp
index fdb59e2..65fac24 100644
--- a/project/NestedLoops.cpp
+++ b/project/NestedLoops.cpp
@@ -13,43 +13,44 @@ void NestedForLoop(size_t n, size_t m)
for (int j = 0; j < m; ++j)
{
cout << "i = " << i << ", j = " << j << endl;
- cout << i * j << endl;
+ cout << "the product of the incrementers are; " << i * j << endl;
}
}
}
-
void NestedWhileLoop(size_t n, size_t m)
{
- n = 0;
- while (n < 4)
+ int i = 0;
+ while (i < n)
{
- m = 0;
- while (m < 3)
+ int j = 0;
+ while (j < m)
{
- cout << "n = " << n << ", m = " << m << endl;
- m++;
+ cout << "n = " << i << ", m = " << j << endl;
+ cout << "the product of the incrementers are; " << i * j << endl;
+ j++;
}
cout << endl;
- n++;
+ i++;
}
}
void NestedDoWhileLoop(size_t n, size_t m)
{
- n = 1;
+ int i = 0;
do
{
- m = 1;
+ int j = 0;
do
{
- cout << n * m << " ";
- ++m;
+ cout << "n = " << i << ", m = " << j << endl;
+ cout << "the product of the incrementers are; " << i * j << endl;
+ j++;
- } while (m <= 3);
+ } while (j <= m);
cout << endl;
- n++;
- } while (n <=3 );
+ i++;
+ } while (i <= n );
}