-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathold_main.cpp
More file actions
43 lines (33 loc) · 941 Bytes
/
Copy pathold_main.cpp
File metadata and controls
43 lines (33 loc) · 941 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
43
#include <iostream>
#include <limits>
int main() {
std::cout << "Wasm-Array\n";
std::cout << "\tMax elements to enter is 6\n";
std::cout << "\tArray type Integer\n";
std::cout << "\tArray numbers 4 - 5 - 1 - 8 - 10 - 2\n\n";
const int max{6};
int numbers[max];
int i{};
std::cout << "Create your own array:\n";
while (i < max) {
std::cout << "\tEnter number [" << i + 1 << "]: ";
std::cin >> numbers[i];
if (std::cin.fail()) {
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
continue;
}
i++;
}
std::cout << "\n";
std::cout << "Your array info:\n";
std::cout << "\tElements entered: ";
for (i = 0; i < max; i++) {
std::cout << numbers[i];
if (i < max - 1) {
std::cout << " - ";
}
}
std::cout << "\n";
return 0;
}