C++ Program to Print Gender using Switch Case

Write C++ Program to Print Gender using Switch Case

// CPP program to print Gender using switch case

#include <iostream>

using namespace std;

int main()
{
	char c;

	cout << "Enter the character F for Female, M for Male, O for Others :--> ";
	cin >> c;

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

	    case 'F':
            case 'f':
			cout << "The Gender is Female";
			break;

	    case 'O':
            case 'o':
			cout << "The Gender is Others";
			break;

	    default:
			cout << "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

≪ Previous | Next ≫