Hi I need help please in my fourth loop I need to output the smallest increase and the biggest increase between two consecutive numbers, but cant figure out how

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Hi I need help please in my fourth loop I need to output the smallest increase and the biggest increase between two consecutive numbers, but cant figure out how

main.cpp x
Console
Shell
es
+
36
int oddsum
0;//adding up total of odd numbers
make -s
37
int increase;//increase in value
C* main.cpp
> . /main
38
int decrease;//decrease in value
Hello World!
39
Enter a number between 1 and 100
40
//third for loop to add up stats of generated random numbers
30
41 ▼
for (int i = 0; i < limit; i++) {
How many columns do you want to display the numbers?
42 ▼
if (random_number[i] % 2 == 0) {
2
43
even++;
44
45 v
else if (!random_number[i] % 2 ==
0) {
32
25
46
odd++;
37
13
34
47
36
49
48 ▼
if (random_number[i] % 2 ==
0) {
21
32
49
evensum+=random_number[i];
50
26
26
51 ▼
0) {
else if (!random_number[i] % 2 ==
oddsum+=random_number[i];
40
32
52
23
47
53
44
54
29
//fourth for loop to check increases, decreases and differences
for (int i = 0; i < limit; i++) {
if (random_number[i+1] < random_number [i]) {
55
10
29
56 v
32
19
57 v
32
34
58
decrease++;
8
49
} else if (random_number[i+1] > random_number[i])
Amount of Odd numbers generated:
13
59
60
increase++;
Amount of Even numbers generated:
17
61
Odd numbers total:
351
62
Even numbers total: 424
63
cout << endl << "Amount of Odd numbers generated:\t" << odd <<
Amount of times number increased:
17
64
endl;
Amount of times number decreased:
12
cout << endl < "Amount of Even numbers generated:\t" << even
<< endl;
cout << "Odd numbers total:\t" << oddsum << endl;
65
66
67
68
cout << "Even numbers total:\t" << evensum << endl;
69
cout << "Amount of times number increased:\t" << increase << endl;
70
cout << "Amount of times number decreased:\t" << decrease << endl;
71
//now I need to add the sum of all odd numbers and all even numbers
72
73
74
RAM
Storage
ץ א
...
..
Transcribed Image Text:main.cpp x Console Shell es + 36 int oddsum 0;//adding up total of odd numbers make -s 37 int increase;//increase in value C* main.cpp > . /main 38 int decrease;//decrease in value Hello World! 39 Enter a number between 1 and 100 40 //third for loop to add up stats of generated random numbers 30 41 ▼ for (int i = 0; i < limit; i++) { How many columns do you want to display the numbers? 42 ▼ if (random_number[i] % 2 == 0) { 2 43 even++; 44 45 v else if (!random_number[i] % 2 == 0) { 32 25 46 odd++; 37 13 34 47 36 49 48 ▼ if (random_number[i] % 2 == 0) { 21 32 49 evensum+=random_number[i]; 50 26 26 51 ▼ 0) { else if (!random_number[i] % 2 == oddsum+=random_number[i]; 40 32 52 23 47 53 44 54 29 //fourth for loop to check increases, decreases and differences for (int i = 0; i < limit; i++) { if (random_number[i+1] < random_number [i]) { 55 10 29 56 v 32 19 57 v 32 34 58 decrease++; 8 49 } else if (random_number[i+1] > random_number[i]) Amount of Odd numbers generated: 13 59 60 increase++; Amount of Even numbers generated: 17 61 Odd numbers total: 351 62 Even numbers total: 424 63 cout << endl << "Amount of Odd numbers generated:\t" << odd << Amount of times number increased: 17 64 endl; Amount of times number decreased: 12 cout << endl < "Amount of Even numbers generated:\t" << even << endl; cout << "Odd numbers total:\t" << oddsum << endl; 65 66 67 68 cout << "Even numbers total:\t" << evensum << endl; 69 cout << "Amount of times number increased:\t" << increase << endl; 70 cout << "Amount of times number decreased:\t" << decrease << endl; 71 //now I need to add the sum of all odd numbers and all even numbers 72 73 74 RAM Storage ץ א ... ..
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY