aboutsummaryrefslogtreecommitdiff
path: root/InClassExercise8/NestedLoops.cpp
blob: 24407f8334a1b6be164e4751cf46be0e9e824bd4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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; }