Function Prototypes

Lab C Beginner 10 points

Declare a prototype int max2(int a, int b); before main, define the function after main, and use it to print the largest of three numbers.

Input

Three integers.

Output

The largest.

Example

Input

3 9 4

Output

9
Sample input available Sample output available
Editor
C

Hints

A prototype tells the compiler a function's signature before its body appears.

Solution explanation

Prototypes let you put main first and still call functions defined later.

Show solution
#include <stdio.h>

int max2(int a, int b);

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    printf("%d\n", max2(max2(a, b), c));
    return 0;
}

int max2(int a, int b) {
    return a > b ? a : b;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD