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

Write a function FindMax() that will accept three variables ( firstnum , secnum

ID: 2083548 • Letter: W

Question

Write a function FindMax()that will accept three variables
(firstnum, secnum, and max), each is of type int. The first and second variables will have a “copy” of their contents sent to the function while the third variable will have its “address” sent to Findmax. Write a program that prompts the user for the first and second numbers and then sends these values along with the variable max’s address to the function. Inside the function, determine which of the two numbers is the larger and place it into max. Hint: A reference to max will have to be accepted by FindMax().

Explanation / Answer

#include <iostream>
using namespace std;
void FindMax(int a,int b,int *max)
{
  
   if(a>b)
   {
       *max=a;
   }
   else
   {
       *max=b;
   }

}
int main() {
int firstNUM=0, secNUM=0;
int max;
   cout<<" Enter two number : ";
   cin>>firstNUM>>secNUM;
  
FindMax(firstNUM,secNUM,&max);
cout<<" maximum of two is: "<<max;
   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