Ask Question
24 November, 02:25

Write the definition of a function named max that receives an int parameter and returns the largest value that it has been called with so far. So, if you make these calls to max, max (5), max (3), max (12), max (4), the values returned will be (respectively) : 5, 5, 12, and 12.

+2
Answers (1)
  1. 24 November, 06:04
    0
    Following are the code in the C language.

    int max (int x) / / function definition

    {

    static int largest=0; / / variable declaration

    if (x>largest) / / checking the condition

    largest=x; / / assign the value of input in the largest variable

    return largest; / / return the largest number

    }

    Explanation:

    Following are the description of code.

    Decalred a function max of int type which hold a parameter x of int datatype. In this function compared the number x with the largest. If this condition is true then largest number hold the value of x variable Finally return the largest number.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write the definition of a function named max that receives an int parameter and returns the largest value that it has been called with so ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers