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

• Write a C program to find maximum of the two numbers using switch case statement.
• How to find maximum of the two numbers using switch statement.

Required Knowledge

• C printf and scanf functions
• Switch case statement in C

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.

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

#include <stdio.h>
#include <conio.h>

int main() {
int a, b;

/* Take two numbers as input from user
using scanf function */
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;
}

getch();
return 0;
}

Output

Enter Two Integers
4 8
8 is Maximum

Enter Two Integers
-2 -4
-2 is Maximum