-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathb.cpp
More file actions
43 lines (37 loc) · 715 Bytes
/
Copy pathb.cpp
File metadata and controls
43 lines (37 loc) · 715 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 statements
#include <cstdlib>
#include <iostream>
using namespace std;
// Main function
int main()
{
// Declare variables
//Step3
int * data;
int number = 0;
// Get user input
cout << "Enter number of values:\n";
cin >> number;
//Step5
if(number < 0)
{
cout << "Overriding user input to 42" << endl;
number = 42;
}
//Step3
data = new int[number];
//Step2
cout << "number = " << number << endl;
// Process data
for (int i = 0; i < number; i++)
{
data[i] = random() % 100;
cout << data[i] << " ";
}
cout << endl;
//Step2
cout << "number = " << number << endl;
//Step 6
delete [] data;
return 0 ;
}