I am currently learning C, and I have had this problem for some time. If it runs, it does not work how it should work, and sometimes it just does not run. It is supposed to if you give a correct answer, you get a point, but even if you get it wrong, it still says its correct and gives you a point. Anyone could help me here? Here is the code:
This works fine
char name[50], answer;
int point;
printf("Enter your name!\n");
scanf("%s", &name);
printf("\t \t \t Welcome to the game, %s! \n", name);
point = 0;
printf("\t \t \t POINTS: %d \n", point);
And here is the question and answer..does not work that well
printf("2+2? \n");
printf("a) 4 \n");
printf("b) 5 \n");
scanf("%s", &answer);
if (answer = "a") {
printf("Correct\n");
point++;
printf("\t \t \t POINTS: %d \n", point);
}
else {
printf("Not correct");
}
printf("2+3? \n");
printf("a) 5 \n");
printf("b) 4 \n");
scanf("%s", &answer);
if (answer = "a") {
printf("Correct\n");
point++;
printf("\t \t \t POINTS: %d \n", point);
}
else {
printf("Not correct");
}