Ask Question
18 January, 11:01

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. 18 January, 11:38
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers