To print gender (Male/Female) according to given M/F.

Write a program to print gender (Male/Female) program according to given M/F.


Source Code:

#include <stdio.h>
#include<conio.h>
void main()
{
    char gender;

    //Reading gender from user
    printf("Enter gender (M/m or F/f): ");
    scanf("%c",&gender);

    switch(gender)
    {
        case 'M':
        case 'm':
            printf("Male");
            break;
        case 'F':
        case 'f':
            printf("Female");
            break;
        default:
            printf("Unspecified Gender\n");
    }

    getch();
}

Output:

Enter gender (M/m or F/f): M
Male

Leave a Reply

Your email address will not be published. Required fields are marked *