I'm trying to get the user of a C program to Enter M for Male and F for Female and to loop through if it doesn't meet M or F . Below I have tried the following code but it loops twice giving the correct answer. For instance after entering M it loops and prints
FALSE gender .. please enter M for Male and M for Female
is there any way to solve it .
The goal is if the user enter M or F it will work without needing to enter it a second time.
if anything else it may ask a number of times
#include "Gender.h"
#include<stdio.h>
char sex;
void Gender(){
printf("\nEnter Student Gender ('example M for Male F for Female):\n");
scanf(" %s",&sex);
while (sex != "M" || sex != "M"){
printf ("\n FALSE gender .. please enter M for Male and M for Female:\n");
scanf(" %s",&sex);
printf("\nStudent Sex :%c", sex,"\n");
return;
}
}