To find maximum number using switch case statement

Write a program to find maximum number using switch case statement.


Source Code:

#include <stdio.h>
#include<conio.h>
void main()
{
    int num1, num2;
   clrscr();
    //Reading two numbers from user
    printf("Enter two numbers to find maximum number: ");
    scanf("%d%d", &num1, &num2);

    //Condition to check maximum number
    switch(num1 > num2)
    {
        case 0: printf("%d is Maximum number", num2);
            break;

        case 1: printf("%d is Maximum number", num1);
            break;
    }

    getch();
}

Output:

Enter two numbers to find maximum number: 
10
20

20 is Maximum number.

Leave a Reply

Your email address will not be published. Required fields are marked *