program is skipping 2nd choice of a,b,c or d. It stops after "Write answer (a/b/c/d):" in that moment, program stops and doesn't let the user choose from the options mentioned before. How can i fix that with some beginner fix? (I'm programming only like 2 weeks) Thanks.
Here's the source code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char choice;
char choice1;
printf("Welcome.\n");
printf("-------------------\n");
printf("Who created Microsoft?\n");
printf("a) Steve Jobs\n");
printf("b) Tim Cook\n");
printf("c) Bill Gates\n");
printf("d) Mark Zuckerberg\n");
printf("\nWrite answer (a/b/c/d): ");
scanf("%c",&choice);
switch(choice)
{
case 'a': printf("\nIncorrect.\n");
break;
case 'b': printf("Incorrect.\n");
break;
case 'c': printf("Correct.\n");
break;
case 'd': printf("Incorrect.\n");
break;
}
printf("Who owns MySQL?\n");
printf("a) Microsoft\n");
printf("b) Apple\n");
printf("c) Google\n");
printf("d) Oracle\n");
printf("\nWrite answer: (a/b/c/d): ");
scanf("%c",&choice1);
switch(choice1)
{
case 'a': printf("Incorrect.\n");
break;
case 'b': printf("Incorrect.\n");
break;
case 'c': printf("Incorrect.\n");
break;
case 'd': printf("Correct.\n");
break;
}
return(EXIT_SUCCESS);
}
Can someone who can make it also explain why did he choose such solution? Thank you in advance.