Question: Part A) Define the function PrintValue() that takes two integer parameters and outputs the sum of all integers starting with the first and ending with

Part A)

Define the function PrintValue() that takes two integer parameters and outputs the sum of all integers starting with the first and ending with the second parameter, followed by a newline. The function does not return any value.

Ex: If the input is 3 5, then the output is:

12 

Note: Assume the first integer parameter is less than the second.

#include using namespace std;

/* Your code goes here */

int main() { int numberA; int numberB;

cin >> numberA; cin >> numberB; PrintValue(numberA, numberB);

return 0; }

Part B)

Given integer variables seedVal and highestInput, generate five random numbers that are less than highestInput and greater than or equal to 0. Each number generated is output. Lastly, the average of the five numbers is output.

Ex: If highestInput is 16, then a possible output is:

7 15 13 3 10 Average: 9.6 

Note: The input seeds are large integers that approximately equal the time in seconds since January 1, 1970.

#include

#include

#include

using namespace std;

int main() {

int seedVal;

int highestInput;

int rand1;

int rand2;

int rand3;

int rand4;

int rand5;

cin >> seedVal;

cin >> highestInput;

#include #include #include using namespace std;

int main() { int seedVal; int highestInput; int rand1; int rand2; int rand3; int rand4; int rand5; cin >> seedVal; cin >> highestInput; srand(seedVal); /* Your code goes here */ cout << rand1 << endl; cout << rand2 << endl; cout << rand3 << endl; cout << rand4 << endl; cout << rand5 << endl; cout << "Average: " << fixed << setprecision(1) << ((rand1 + rand2 + rand3 + rand4 + rand5) / 5.0) << endl; return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!