-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStar_Patterns.cpp
More file actions
85 lines (64 loc) · 1.71 KB
/
Star_Patterns.cpp
File metadata and controls
85 lines (64 loc) · 1.71 KB
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
// "If you think it's simple, then you have misunderstood the problem." - Bjarne Stroustrup
#include <iostream>
using namespace std;
int main()
{
int stars = 5;
int balls = 1;
int balls2 = 1;
cout << "For Loop Vertical\n";
for(int i = 0; i < stars; i++){
cout << "* \n";
}
cout << "While Loop Vertical\n";
while(balls <= stars){
balls++;
cout << "* \n";
}
cout << "For Loop Horizontal\n";
for(int i = 0; i < stars; i++){
cout << "* ";
}
cout << "While Horizontal\n";
while(balls2 <= stars){
balls2++;
cout << "* ";
}
cout << "Mew\n";
for(int j = 1; j <= stars; j++){
for(int k = 1; k <= stars; k++){
cout << "* ";
}
cout <<"\n";
}
int balls3 = 1;
int balls4 = 1;
while(balls3 <= stars){
balls3++;
while(balls4 <= stars){
balls4++;
cout <<"* ";
}
cout << "\n";
}
// Use a For Loop and a While loop to complete these questions:
// 1) Write a program that prints 5 stars in a line (easy)
// Output: * * * * *
// ------------------------------------------------------------------------
// 2) Write a program that prints 5 stars, each on a new line (medium)
// Output:
// *
// *
// *
// *
// *
// ------------------------------------------------------------------------
// 3) Write a program that prints 25 stars (5 rows and 5 columns) (hard)
// Output:
// * * * * *
// * * * * *
// * * * * *
// * * * * *
// * * * * *
return 0;
}