This is because %c
accepts '\n'
symbol that's left over from entering the age. You would be better off reading into a string, and taking the first character, like this:
char buf[2];
printf("Enter your gender (m/f): ");
scanf("%1s", buf);
gender = buf[0];
printf("\nEnter your marital status (m/u): ");
scanf("%1s", buf);
marital_status = buf[0];
The %s
format specifier is set up to ignore all whitespace. Note the one character limit after %
in the format specifier.