forked from vectormars/CPP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC83 Break-and-continue.cpp
53 lines (43 loc) · 1.06 KB
/
C83 Break-and-continue.cpp
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
#include <iostream>
using namespace std;
/* loops - break and continue */
main()
{
/*
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 ....
4 ...
5 ...
*/
/*
for (int i = 1; i <= 10; i++) //amount of rows, length of column
{
if (i == 5)
continue; //EVERYTHING AFTER continue instruction WONT BE executed BUT LOOP WON'T END BECAUSE OF IT
if (i == 5)
break; //EVERYTHING after break WON't be executed AND we are LEAVING the ACTUAL LOOP
for (int j = 1; j <= 10; j++) //amount of columns, length of row
{
if (j == 5)
continue;
cout.width(4);
cout << i * j;
}
cout << endl;
}
*/
for (int i = 1, j = 1; i <= 10; i++)
{
cout.width(4);
cout << i * j;
if (i == 10)
{
j++;
i = 0;
cout << endl;
}
if (j == 10 + 1)
break;
}
}