blob: 30f7077e6b6f78f20543f852c7abe3d13f2a60b4 (
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
// Name: Connor McDowell
// date: 1/29/2024
// class: CIS116
// Reason: inclass exercise 7
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
//notes
//loop types and examples
//void ForLoopExamples();
//void WhileLoopExamples();
//void DoWhileLoopExamples();
int main()
{
//ForLoopExamples();
//WhileLoopExamples();
//DoWhileLoopExamples();
return 0;
}
void DoWhileLoopExamples()
{
/*int i = 0;
do
{
cout << i << " ";
++i;
} while (i < 10);*/
/*int countdown = 10;
do
{
cout << "Countdown: " << countdown << endl;
countdown--;
} while (countdown > 0);*/
/*int num;
do
{
cout << "enter a number (0 to exit): ";
cin >> num;
cout << "you entered: " << num << endl;
} while (num != 0);*\
}
void WhileLoopExamples()
{
// decare counter first
/*int i = 0;
while (i < 100)
{
std::cout << i << " ";
++i;
}*/
// infinite loop because true is always true
// reinitialize variables every time
/*int i = 0;
while (i < 10 && i !=5)
{
std::cout << i << " ";
++i;
}*/
/*int j = 10;
int i = 0;
while (i < 5 && j > 5)
{
cout << i << "," << j << endl;
++i;
j--;
}*/
}
void ForLoopExamples()
{
//for (int i = 0; i < 10; ++i)
//{
// std::cout << i << " ";
//}
//for (int i = 10; i > 0; --i);
//{
// std::cout << i << " ";
//}
//int i, k, j, m, n;
//for (auto i = 0; j = 5; i < 5; ++i; --j)
//{
// std::cout << i << " " << j << std::endl;
//
//}
/*for (int i = 0; i < 10 && i != 5; ++i)
{
std::cout << i << " ";
}*/
/*for(auto i = 0, j = 4; (i < 100) || (j > 0); ++i, --j)
{
std::cout << i << " " << j << std::endl;
}*/
}
|