Lab 7: Arrays Using the Lab07.cpp file, implement a function named difference that returns the difference between the largest and smallest values in an array. Example: Sequence given: 7, 2, 10, 9 Largest value: 10 Smallest value: 2 Return value: (10 - 2) = 8 The main function already contains test cases. Write function comments as shown in lesson 5.

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
/*
(name header)
#include <iostream>
// Function declaration
int main()
{
int al[]
int a2[] = { 7, 2, 10, 9 };
int a3[] = { 2, 10, 7, 2 };
int a4[] = { 2, 10 };
int a5[] = { 10, 2 };
int a6[] = { 2, 3 };
int a7[] = { 2, 2 };
int a8[] = { 2 };
int a9[] % { 5, 1, б, 1, 9, 9 };
int al0[] = { 7, 6, 8, 5 };
int all[] = { 7, 7, 6, 8, 5, 5, 6 };
int al2[] = { 10, 0 };
{ 10, 3, 5, 6 };
%3D
std::cout
« ((difference (al, 4)
« ((difference(a2, 4)
<« ((difference (a3, 4)
« ((difference(a4, 2)
<« ((difference (a5, 2)
<« ((difference (a6, 2)
<« ((difference (a7, 2)
<« ((difference(a8, 1)
« ((difference (a9, 6)
« ((difference(a10, 4)
" <« ((difference(al1, 7)
« ((difference (al2, 2) == 10) ? "OK\n" : "X\n");
<< "al:
<< "a2:
%3D
7)? "OK" : "X") << std::endl
== 8) ? "OK\n" : "X\n")
8) ? "OK\n" : "X\n")
== 8) ? "OK\n" : "X\n")
== 8) ? "OK\n" : "X\n")
== 1) ? "OK\n" : "X\n")
== 0) ? "OK\n" : "X\n")
0) ? "OK\n" : "X\n")
== 8) ? "OK\n" : "X\n")
== 3) ? "OK\n" : "X\n")
== 3) ? "OK\n" : "X\n")
==
<< "a3:
==
<< "a4:
<< "a5:
<< "a6:
<< "a7:
<< "a8:
==
<< "a9:
<< "a10:
<< "all:
<« "a12: "
std::cout « "\n";
return 0;
}
//Function definition
Transcribed Image Text:/* (name header) #include <iostream> // Function declaration int main() { int al[] int a2[] = { 7, 2, 10, 9 }; int a3[] = { 2, 10, 7, 2 }; int a4[] = { 2, 10 }; int a5[] = { 10, 2 }; int a6[] = { 2, 3 }; int a7[] = { 2, 2 }; int a8[] = { 2 }; int a9[] % { 5, 1, б, 1, 9, 9 }; int al0[] = { 7, 6, 8, 5 }; int all[] = { 7, 7, 6, 8, 5, 5, 6 }; int al2[] = { 10, 0 }; { 10, 3, 5, 6 }; %3D std::cout « ((difference (al, 4) « ((difference(a2, 4) <« ((difference (a3, 4) « ((difference(a4, 2) <« ((difference (a5, 2) <« ((difference (a6, 2) <« ((difference (a7, 2) <« ((difference(a8, 1) « ((difference (a9, 6) « ((difference(a10, 4) " <« ((difference(al1, 7) « ((difference (al2, 2) == 10) ? "OK\n" : "X\n"); << "al: << "a2: %3D 7)? "OK" : "X") << std::endl == 8) ? "OK\n" : "X\n") 8) ? "OK\n" : "X\n") == 8) ? "OK\n" : "X\n") == 8) ? "OK\n" : "X\n") == 1) ? "OK\n" : "X\n") == 0) ? "OK\n" : "X\n") 0) ? "OK\n" : "X\n") == 8) ? "OK\n" : "X\n") == 3) ? "OK\n" : "X\n") == 3) ? "OK\n" : "X\n") == << "a3: == << "a4: << "a5: << "a6: << "a7: << "a8: == << "a9: << "a10: << "all: <« "a12: " std::cout « "\n"; return 0; } //Function definition
Lab 7: Arrays
Using the Lab07.cpp file, implement a function named difference that returns the difference between
the largest and smallest values in an array.
Example:
Sequence given: 7, 2, 10, 9
Largest value: 10
Smallest value: 2
Return value: (10 - 2) = 8
The main function already contains test cases.
Write function comments as shown in lesson 5.
What does the function return? Which parameters to pass? Examine the code provided to determine
return type and parameters.
Transcribed Image Text:Lab 7: Arrays Using the Lab07.cpp file, implement a function named difference that returns the difference between the largest and smallest values in an array. Example: Sequence given: 7, 2, 10, 9 Largest value: 10 Smallest value: 2 Return value: (10 - 2) = 8 The main function already contains test cases. Write function comments as shown in lesson 5. What does the function return? Which parameters to pass? Examine the code provided to determine return type and parameters.
Expert Solution
trending now

Trending now

This is a popular 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