C Program to Find Maximum of Two Numbers using Switch Case Statement

In this C program, we will find maximum of the two numbers using switch statement. We will first take two numbers as input from user using scanf function. Then we print the maximum number on screen using switch case statement.

Required Knowledge


C program to find maximum of two numbers using switch case statement

#include <stdio.h>
  
int main() {  
    int a, b;  
  
    printf("Enter Two Integers\n");  
    scanf("%d %d", &a, &b);  
  
    switch(a > b) {     
        /* a>b comparison returns true(1)  */  
        case 1: printf("%d is Maximum", a);  
                break;  
        /* a>b comparison returns false(0) */  
        case 0: printf("%d is maximum", b);  
                break;  
    }  
    return 0;
}
Output
Enter Two Integers
4 8
8 is Maximum
Enter Two Integers
-2 -4
-2 is Maximum

Related Topics
C program to find maximum of two numbers
C program to find maximum of two numbers using conditional operator
C program to find maximum of three numbers
C program to find maximum of three numbers using conditional operator
C program to make a simple calculator using switch statement
C Program to generate geometric progression(GP) series
C program to add two complex numbers
C program to check year is leap year or not
C program to find gcd of two numbers
List of all C programs