9.0k views
2 votes
Do the same exercise but this time use the value returning function. Here is the skeleton of the main function. Write functions definition according to the function call. Note: Do not change the main(). Copy it as it is. Must define the function after the main(). Make sure you write the function prototype before main(). // function prototype.

User Bobbogo
by
4.6k points

1 Answer

6 votes

Answer:

The function prototypes are as follows:

int findSum(int fn, int sn, int tn);

int findMin(int fn, int sn, int tn);

int findMax(int fn, int sn, int tn);

The functions are as follows:

int findSum(int fn, int sn, int tn){

return fn+sn+tn;}

int findMin(int fn, int sn, int tn){

int min = fn;

if(sn<=min && sn<=tn){

min = sn; }

if(tn <= min && tn <= sn){

min = tn; }

return min;}

int findMax(int fn, int sn, int tn){

int max = fn;

if(sn>=max && sn>=tn){

max = sn; }

if(tn>=max && tn>=sn){

max = tn; }

return max;}

Step-by-step explanation:

Given

See attachment 1 for the main function

Required

Write the following functions

  • findSum
  • find Min
  • findMax.

The following represents the function prototypes

int findSum(int fn, int sn, int tn);

int findMin(int fn, int sn, int tn);

int findMax(int fn, int sn, int tn);

This declares the findSum function

int findSum(int fn, int sn, int tn){

This returns the sum of the three numbers

return fn+sn+tn;}

This declares the findMin function

int findMin(int fn, int sn, int tn){

This initialzes min (i.e. minumum) to fn

int min = fn;

This checks if sn is the minimum

if(sn<=min && sn<=tn){

min = sn; }

This checks if tn is the minimum

if(tn <= min && tn <= sn){

min = tn; }

This returns the minimum of the three numbers

return min;}

This declares the findMax function

int findMax(int fn, int sn, int tn){

This initialzes max (i.e. maximum) to fn

int max = fn;

This checks if sn is the maximum

if(sn>=max && sn>=tn){

max = sn; }

This checks if tn is the maximum

if(tn>=max && tn>=sn){

max = tn; }

This returns the maximum of the three numbers

return max;}

See cpp attachment for complete program which includes the main

Do the same exercise but this time use the value returning function. Here is the skeleton-example-1
User Tiktak
by
5.2k points