C (ANSI)

#include <stdio.h>

// Function to find the maximum of two numbers
int max(int num1, int num2) {
    return (num1 > num2) ? num1 : num2;
}

// Function to find the maximum of three numbers
int maxOfThree(int num1, int num2, int num3) {
    return max(max(num1, num2), num3);
}

// Main function
int main() {
    // Declare variables
    int num1, num2, num3;

    // Input three numbers from the user
    printf("Enter three numbers: ");
    scanf("%d %d %d", &num1, &num2, &num3);

    // Find and print the maximum of the three numbers
    printf("Maximum number is: %d", maxOfThree(num1, num2, num3));

    // Return 0 to indicate successful completion
    return 0;
}

Explanation:

  1. Include Header File:#include <stdio.h> includes the standard input-output library for using functions like printf and scanf.

  2. Function Declaration:int max(int num1, int num2) declares a function named max that takes two integer parameters and returns an integer. It is used to find the maximum of two numbers.

  3. maxOfThree Function Declaration:int maxOfThree(int num1, int num2, int num3) declares a function named maxOfThree that takes three integer parameters and returns an integer. It utilizes the max function to find the maximum of three numbers.

  4. Main Function:int main() is the main function where the program execution starts.

  5. Variable Declaration:int num1, num2, num3; declares three integer variables to store user-input numbers.

  6. User Input:printf("Enter three numbers: "); scanf("%d %d %d", &num1, &num2, &num3); prompts the user to enter three numbers, and scanf is used to read and store these values.

  7. Function Call:maxOfThree(num1, num2, num3) calls the maxOfThree function with the user-input numbers as arguments.

  8. Print Result:printf("Maximum number is: %d", maxOfThree(num1, num2, num3)); prints the result, which is the maximum of the three numbers.

  9. Return Statement:return 0; indicates the successful completion of the program.