-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrectanglePatternArray.cpp
More file actions
64 lines (57 loc) · 1.26 KB
/
rectanglePatternArray.cpp
File metadata and controls
64 lines (57 loc) · 1.26 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
// Problem: Print the rectangle pattern from the array given by user.
// Input: 1 2 3 4
// Output:
// 1 2 3 4
// 1 2 3 4
// 1 2 3 4
// 1 2 3 4
#include <iostream>
using namespace std;
void withForLoop (int arr[50], int size) {
int i, j;
for (i=0; i<size; i++) {
for (j=0; j<size; j++) {
cout << arr[j] << " ";
}
cout << endl;
}
}
// void withWhileLoop (int arr[50], int size) {
// int i;
// i=1;
// while (i <= size) {
// int j=0;
// while (j < size) {
// cout << arr[j] << " ";
// j++;
// }
// cout << endl;
// i++;
// }
// }
// void withDoWhileLoop (int arr[50], int size) {
// int i=1, j;
// do {
// j = 0;
// do {
// cout << arr[j] << " ";
// j++;
// } while (j < size);
// cout << endl;
// i++;
// } while (i <= size);
// }
int main() {
int arr[50], size, i;
cout << "Enter size of array or grid you want: ";
cin >> size;
cout << "Enter values of array: ";
for (i=0; i<size; i++) {
cin >> arr[i];
}
cout << endl;
withForLoop (arr, size);
// withWhileLoop (arr, size);
// withDoWhileLoop (arr, size);
return 0;
}