Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ functions Main will call function Prompt, three times. Then call Max_Value a

ID: 675040 • Letter: C

Question

C++ functions

Main will call function Prompt, three times. Then call Max_Value and then Min_Value, each once. Prompt will accept no parameters and return one integer value. Max_Value will accept three integer values and then output the following: an echo of the values, the maximum value of the first two values, the maximum of the last two values and then the maximum of all of the values. This function will not return anything. Min_Value will do the exact same thing as Max_Value but with minimum values instead of maximum.

Explanation / Answer

#include<iostream>

using namespace std;

int Prompt() {

int n;

   cout<<"Enter an integer: ";

cin>>n;

return n;

}

void Max_Value(int a, int b, int c) {

cout<<"Values are: "<<a<<", "<<b<<" and "<<c<<" ";

  

int max1,max2,max;

max1 = (a>b) ? a : b;

max2 = (b>c) ? b : c;

max = (max1 > c) ? max1 : c;

cout<<"Max of "<<a<<" and "<<b<<" is: "<<max1<<" ";

cout<<"Max of "<<b<<" and "<<c<<" is: "<<max2<<" ";

cout<<"Max of "<<a<<", "<<b<<" and "<<c<<" is: "<<max<<" ";

}

void Min_Value(int a, int b, int c) {

cout<<"Values are: "<<a<<", "<<b<<" and "<<c<<" ";

  

int min1,min2,min;

min1 = (a<b) ? a : b;

min2 = (b<c) ? b : c;

min = (min1 > c) ? min1 : c;

cout<<"Min of "<<a<<" and "<<b<<" is: "<<min1<<" ";

cout<<"Min of "<<b<<" and "<<c<<" is: "<<min2<<" ";

cout<<"Min of "<<a<<", "<<b<<" and "<<c<<" is: "<<min<<" ";

}

int main() {

int a = Prompt();

int b = Prompt();

int c = Prompt();

  

Max_Value(a, b, c);

Min_Value(a, b, c);

  

cout<<" ";

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote