Do While error prints twice despite scanf
I am trying to teach myself C and decided to make a console project that would be a Basal Metabolic Weight/BMI/Calorie Calculator. Anyways I am stumped early on with this problem. Can anyone tell me where I went wrong? I have been racking my brain but haven't been able to figure it out. (But I am somewhat new at this) Thanks!!!
Melissa
Code:
#include <stdio.h>
int main()
{
char Gender = 'a';
char tempGender;
//Title
printf("WEIGHT LOSS CALCULATOR \n\n\n");
//Gather gender info
do {
printf("Are you male or female? \nType M for male and F for female.\n\n");
scanf("%c", &tempGender);
//printf("%c",tempGender\n);
if (tempGender == 'm' || tempGender == 'M') {
Gender = 'm';
printf("You are a male.\n\n");
}
else if (tempGender == 'f'|| tempGender == 'F') {
Gender = 'f';
printf("You are a female.\n\n");
}
else {
printf("ERROR. Please try again.\n\n");
printf("You typed: %c\n",tempGender);
}
}while (Gender == 'a');
return 0;
}