output function problem

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
using namespace std;
// CalculateMaximum.cpp

int main()
{
   // prototype
   int findMax(int, int);  // the function declaration (prototype)

   int firstnum;
   int secnum;
   int maxNumber = 0;

   cout << "\nEnter a number: ";
   cin  >> firstnum;

   cout << "Great! Please enter a second number: ";
   cin  >> secnum;

   //          function call
   maxNumber = findMax(firstnum, secnum);  // the function is called here

   cout << "\nThe maximum of the two numbers is "
        << maxNumber << endl;

   cin.get();
   return 0;
}


//-------------------------------------------------------------------
// Output Function - code the findMax() function below
//-------------------------------------------------------------------



Would the Output Function look something like this..??

1
2
3
4
int findMax ()
{
 cout << maxNumber << endl;
}


I feel like I'm missing something to this one..?
Hi @CRooky,
would be something
like this:

1
2
3
4
5
int findMax(int a,int b){
      if(a>b) return a;

return b;
}//end function findMax 
oh ok that makes sense eyenrique but why not use an else to return b?
You could use an
if-else anyway;
the function procedure
finishes when
an integer is returned
so: if a is greater than b
a is returned or
if a is equal or less
than b; b is returned;

Topic archived. No new replies allowed.