C Program to Print Gender using Switch Case

C Program to Print Gender using Switch Case

Write C Program to Print Gender using Switch Case

//Write a C program to print Gender using the switch case

#include <stdio.h>

int main()
{
	char c;

	printf("Enter the character F for Female, M for Male, O for Others :--> ");
	scanf("%c", &c);

	switch(c)
	{
		case 'M':
        case 'm':
			printf("The Gender is Male");
			break;

		case 'F':
        case 'f':
			printf("The Gender is Female");
			break;

		case 'O':
        case 'o':
			printf("The Gender is Others");
			break;

		default:
			printf("Please enter the correct input");
			break;
	}
	return 0;
}

Output:

Run 1:
Enter the character F for Female,M for Male, O for Others :--> M
The Gender is Male

Run 2:
Enter the character F for Female,M for Male, O for Others :--> a
Please enter the correct inputs

Run 3:
Enter the character F for Female, M for Male, O for Others :--> O
The Gender is Others