Computer Science, asked by sspal8942, 4 months ago

Question 3: Write a program that inputs two numbers in main() function, passes these numbers to a function. The function displays the maximum number.

Answers

Answered by lizzgiri1504
1

Answer:

Say max() function is used to find maximum between two numbers. Second, we need to find maximum between two numbers. Hence, the function must accept two parameters of int type say, max(int num1, int num2) . Finally, the function should return maximum among given two numbers.

Answered by krithikasmart11
0

Answer:

written below-

Explanation:

First give a meaningful name to our function. Say max() function is used to find maximum between two numbers.

Second, we need to find maximum between two numbers. Hence, the function must accept two parameters of int type say, max(int num1, int num2).

Finally, the function should return maximum among given two numbers. Hence, the return type of the function must be same as parameters type i.e. int in our case.

After combining the above three points, function declaration to find maximum is int max(int num1, int num2);

include <stdio.h>

/* Function declarations */

int max(int num1, int num2);

int min(int num1, int num2);

int main()

{

int num1, num2, maximum, minimum;

/* Input two numbers from user */

printf("Enter any two numbers: ");

scanf("%d%d", &num1, &num2);

maximum = max(num1, num2); // Call maximum function

minimum = min(num1, num2); // Call minimum function

printf("\nMaximum = %d\n", maximum);

printf("Minimum = %d", minimum);

return 0;

}

#SPJ2

Similar questions