Home

A program to find maximum of two numbers using IF ELSE

C Programming Language 017

The following code shows how to write a program to explain IF ELSE. To find maximum of two numbers.

Program

#include <stdio.h>

void main()
{
    int a, b;
    printf("Enter two numbers: ");
    scanf("%d %d", &a, &b);

    if (a > b)
    {
        printf("Maximum = %d", a);
    }
    else
    {
        printf("Maximum = %d", b);
    }

    printf("\n");
}

Result

Enter two numbers: 40 35
Maximum = 40


Last Updated on

Next Post: Rules vs Guidelines →

Comments