aboutsummaryrefslogtreecommitdiff
path: root/InClassExercise8/NestedLoops.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'InClassExercise8/NestedLoops.cpp')
-rw-r--r--InClassExercise8/NestedLoops.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/InClassExercise8/NestedLoops.cpp b/InClassExercise8/NestedLoops.cpp
index e69de29..24407f8 100644
--- a/InClassExercise8/NestedLoops.cpp
+++ b/InClassExercise8/NestedLoops.cpp
@@ -0,0 +1,44 @@
+// Name: Asahel
+// Date: 1/31/24
+// Class: CST 116
+// Assignment: InClassExercise8
+
+#include <iostream>
+#include "NestedLoops.h"
+
+using std::cout;
+using std::cin;
+using std::endl;
+
+void NestedForLoopExamples();
+void NestedWhileLoopExamples();
+void NestedDoWhileLoopExamples();
+
+int main() {
+
+ NestedForLoopExamples();
+ {
+
+ for (int i = 0, j = 5; i < 5; ++i, --j)
+ cout << i << " " << j << "\n";
+
+ }
+ NestedWhileLoop(5, 10); {
+ int j = 10;
+ int i = 0;
+ while (i < 5 && j > 5) {
+ cout << i << "," << j << " ";
+ i++;
+ j--; }
+
+ NestedDoWhileLoop(5, 10); {
+
+ int j = 10;
+ i = 0;
+ do {
+ cout << i << "," << j << " ";
+ i++;
+ j--;
+ } while (i < 5 && j > 5);
+
+ return 0; } \ No newline at end of file