Ordinarily, when scanf is processing your input, it will ignore all spaces, tabs and newlines.
But this doesn't happen when you're using the %c conversion, it will take the next character regardless.
Try this program to see.
Code:
#include <stdio.h>
int main()
{
/* There was no need for these to be global variables */
char answer, answertwo;
printf ("Are you laughing? (Y/N)\n" );
scanf ("%c", &answer);
printf("You entered character %d\n", answer );
if (answer == 'y' || answer == 'Y')
printf("\nGood\n");
else if (answer == 'n' || answer == 'N')
printf("\nBye\n");
printf("Do you want to read? (Y/N)\n ");
scanf ("%c, &answertwo");
printf("You entered character %d\n", answertwo );
if (answertwo == 'y' || answertwo == 'Y')
printf("\nGood\n");
else if (answertwo == 'n' || answertwo == 'N')
printf("\nBye\n");
return 0;
}
You should see that you get 10 printed (which is the ASCII for newline) at the second print statement.
Fortunately, the solution is very easy.
Code:
/* Put a leading space before the %c character to skip leading blank characters */
scanf (" %c", &answer);