Index « Previous Next »

Question

Write a function named biggest that receives three integer arguments and returns the largest of the three values.

Call this function from main( ) and print the biggest number.

Source Code

#include <stdio.h>

int biggest(int, int, int);

int main()
{
    int num1, num2, num3, max;
    printf("Enter three numbers : ");
    scanf("%d%d%d", &num1, &num2, &num3);

    max = biggest(num1, num2, num3);
    printf("The biggest number is %d", max);

    return 0;
}

int biggest(int a, int b, int c)
{
    if (a > b && a > c)
    {
        return a;
    }
    else if (b > c)
    {
        return b;
    }
    else
    {
        return c;
    }
}

Output

Enter three numbers : 18 6 25
The biggest number is 25