#include <stdio.h>
int main()
{
int a, b, c;
/* Input two numbers from user */
printf("Enter two numbers to find maximum: ");
scanf("%d%d", &a, &b);
c = a > b;
switch (c)
{
case 0:
printf("%d is maximum", b);
break;
case 1:
printf("%d is maximum", a);
break;
default:
printf("Invalid Input");
}
return 0;
}
I want to print default statement in this C program by entering wrong input like float or character const. Whenever I enter any char type variable or floating point number this happens
Output example 1:
Enter two numbers to find maximum: 2.5
509 is maximum
Output example 2:
Enter two numbers to find maximum: g
512 is maximum
Expected Output should be:
Enter two numbers to find maximum: g
Invalid Input
Expected Output should be:
Enter two numbers to find maximum: 22.6
Invalid Input