aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrPatrickWarner <[email protected]>2024-01-29 21:37:29 -0800
committerrPatrickWarner <[email protected]>2024-01-29 21:37:29 -0800
commite1379103a881223102dc57eaae42c19efd38634c (patch)
tree2f5485f6ee0bc28c0bc4bb956a12c60bf3e77879
parentinit (diff)
downloadin-class-exercise-8-reecepwarner-e1379103a881223102dc57eaae42c19efd38634c.tar.xz
in-class-exercise-8-reecepwarner-e1379103a881223102dc57eaae42c19efd38634c.zip
completedHEADmain
-rw-r--r--inclassexercise8reece/inclassexercise8reece/nestedloops.cpp40
-rw-r--r--inclassexercise8reece/inclassexercise8reece/program.cpp25
2 files changed, 58 insertions, 7 deletions
diff --git a/inclassexercise8reece/inclassexercise8reece/nestedloops.cpp b/inclassexercise8reece/inclassexercise8reece/nestedloops.cpp
index 9744cff..82e5242 100644
--- a/inclassexercise8reece/inclassexercise8reece/nestedloops.cpp
+++ b/inclassexercise8reece/inclassexercise8reece/nestedloops.cpp
@@ -8,16 +8,52 @@ 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 << " * " << j << " = " << i * j << endl;
+ }
}
void nestedWhileloop(size_t n, size_t m)
{
-
+ int i = 0;
+
+ while (i <= n)
+ {
+ int j = 0;
+ while (j <= m)
+ {
+ cout << i << " * " << j << " = " << i * j << endl;
+ j++;
+ }
+ cout << endl;
+ i++;
+
+ }
}
void nestedDoWhileloop(size_t n, size_t m)
{
+ int i = 0;
+ do
+ {
+ int j = 0;
+ do
+ {
+ cout << i << " * " << j << " = " << i * j << endl;
+
+ j++;
+
+ } while (j<=m);
+
+ i++;
+
+ } while (i<=n);
+
+
+
+
}
diff --git a/inclassexercise8reece/inclassexercise8reece/program.cpp b/inclassexercise8reece/inclassexercise8reece/program.cpp
index 14ff32d..a86679c 100644
--- a/inclassexercise8reece/inclassexercise8reece/program.cpp
+++ b/inclassexercise8reece/inclassexercise8reece/program.cpp
@@ -12,11 +12,26 @@ using std::endl;
int main()
{
-
-
-
-
-
+ int num;
+ int ja;
+ cout << "\nGive me a number to act as a limit" << endl;
+ cin >> num;
+ cout << "\nGive me a second number to act as limit" << endl;
+ cin >> ja;
+ nestedForloop(num, ja);
+
+ cout << "\nGive me another number to act as a limit" << endl;
+ cin >> num;
+ cout << "\nGive me a second limiting number" << endl;
+ cin >> ja;
+ nestedWhileloop(num, ja);
+
+
+ cout << "\nGive me another limiting number" << endl;
+ cin >> num;
+ cout << "\nGive me one final limiting number" << endl;
+ cin >> ja;
+ nestedDoWhileloop(num, ja);