#include <stdio.h>
int main() {
int month;
printf("Enter the month (1-12): ");
scanf("%d", &month);
switch (month) {
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
printf("31 days\n");
break;
case 4: case 6: case 9: case 11:
printf("30 days\n");
break;
case 2:
printf("28 or 29 days\n");
break;
default:
printf("Invalid month\n");
}
return 0;
}
#include <stdio.h>
int main() {
int day;
printf("Enter a day of the week (1-7): ");
scanf("%d", &day);
switch (day) {
case 1:
printf("Monday\n");
break;
case 2:
printf("Tuesday\n");
break;
case 3:
printf("Wednesday\n");
break;
case 4:
printf("Thursday\n");
break;
case 5:
printf("Friday\n");
break;
case 6:
printf("Saturday\n");
break;
case 7:
printf("Sunday\n");
break;
default:
printf("Invalid day\n");
}
return 0;
}
#include <stdio.h>
int main() {
char operator;
double num1, num2;
printf("Enter an operator (+, -, *, /): ");
scanf(" %c", &operator);
printf("Enter two numbers: ");
scanf("%lf %lf", &num1, &num2);
switch (operator) {
case '+':
printf("%.2lf + %.2lf = %.2lf\n", num1, num2, num1 + num2);
break;
case '-':
printf("%.2lf - %.2lf = %.2lf\n", num1, num2, num1 - num2);
break;
case '*':
printf("%.2lf * %.2lf = %.2lf\n", num1, num2, num1 * num2);
break;
case '/':
if (num2 != 0) {
printf("%.2lf / %.2lf = %.2lf\n", num1, num2, num1 / num2);
} else {
printf("Error: Division by zero\n");
}
break;
default:
printf("Invalid operator\n");
}
return 0;
}
#include <stdio.h>
int main() {
int number;
printf("Enter an integer: ");
scanf("%d", &number);
switch (number % 2) {
case 0:
printf("Even number\n");
break;
case 1:
case -1:
printf("Odd number\n");
break;
}
return 0;
}
#include <stdio.h>
int main() {
char ch;
printf("Enter a character: ");
scanf(" %c", &ch);
switch (ch) {
case 'a': case 'e': case 'i': case 'o': case 'u':
case 'A': case 'E': case 'I': case 'O': case 'U':
printf("Vowel\n");
break;
default:
printf("Consonant\n");
}
return 0;
}
#include <stdio.h>
int main() {
char gender;
printf("Enter your gender (M/F): ");
scanf(" %c", &gender);
switch (gender) {
case 'M':
case 'm':
printf("Male\n");
break;
case 'F':
case 'f':
printf("Female\n");
break;
default:
printf("Unknown gender\n");
}
return 0;
}
#include <stdio.h>
#include
int main() {
double num1, num2, num3;
printf("Enter three numbers: ");
scanf("%lf %lf %lf", &num1, &num2, &num3);
if (num1 >= num2 && num1 >= num3)
printf("Maximum number: %.2lf\n", num1);
else if (num2 >= num1 && num2 >= num3)
printf("Maximum number: %.2lf\n", num2);
else
printf("Maximum number: %.2lf\n", num3);
return 0;
}