blob: 65fac242776b48ad5917aab4431de49ecad9b8d4 (
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
45
46
47
48
49
50
51
52
53
54
55
56
|
#include "NestedLoops.h"
#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 << "the product of the incrementers are; " << i * j << endl;
}
}
}
void NestedWhileLoop(size_t n, size_t m)
{
int i = 0;
while (i < n)
{
int j = 0;
while (j < m)
{
cout << "n = " << i << ", m = " << j << endl;
cout << "the product of the incrementers are; " << i * j << endl;
j++;
}
cout << endl;
i++;
}
}
void NestedDoWhileLoop(size_t n, size_t m)
{
int i = 0;
do
{
int j = 0;
do
{
cout << "n = " << i << ", m = " << j << endl;
cout << "the product of the incrementers are; " << i * j << endl;
j++;
} while (j <= m);
cout << endl;
i++;
} while (i <= n );
}
|