Part A Write a C program that that finds the maximum value

Part A ) Write a C++ program that that finds the maximum value of the three. You must create a main function with a loop. Name the function \"max\" that returns the maximum value of the three values passed to it. It also must work with any three numbers.

Example Output:

Part B) Write a flowchart of your program and list all the combinations.

(please make sure to include the flowchart)

Solution

#include<iostream>

#include<string.h>

using namespace std;

int max(int a, int b, int c) {

if(a>b) {

if(a>c)

return a;

else

return c;

} else {

if(b>c)

return b;

else

return c;

}

}

int main() {

  

for (int i=0; i<6; i++) {

cout<<\"Please enter three numbers seperated by space: \";

int a,b,c;

cin>>a>>b>>c;

  

cout<<\"The maximum number is: \"<<max(a, b, c)<<\"\ \";

}

  

  

cout<<\"\ \ \";

return 0;

}


Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site