-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram_01.cpp
More file actions
42 lines (36 loc) · 814 Bytes
/
program_01.cpp
File metadata and controls
42 lines (36 loc) · 814 Bytes
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
// Printing 0-100 numbers and only 20 digits per row.
// Language: C++
// Using For Loop:
// **************************************
for(int i = 1; i < 101; i++){
std::cout << i << " ";
if(i % 20 == 0)
{
std::cout << '\n';
}
}
// Using While loop:
// ****************************************
int count = 1;
while(count < 101)
{
std::cout << count << " ";
if( count % 20 == 0 )
{
std::cout << '\n';
}
count++;
}
// Using do-while loop:
//******************************************
int count = 1;
do
{
std::cout << count << " ";
if(count % 20 == 0)
{
std::cout << '\n';
}
count++;
}
while(count < 101);