Skip to content

Commit c7a7a5d

Browse files
authored
Sorting arrays in ascending order
1 parent 20e68b4 commit c7a7a5d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Arrays/array.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int numbers[5];
6+
7+
cout << "Enter 5 numbers: " << endl;
8+
9+
// store input from user to array
10+
for (int i = 0; i < 5; ++i) {
11+
cin >> numbers[i];
12+
}
13+
14+
cout << "The numbers are: ";
15+
16+
// print array elements
17+
for (int n = 0; n < 5; ++n) {
18+
cout << numbers[n] << " ";
19+
}
20+
21+
return 0;
22+
}

0 commit comments

Comments
 (0)