#include <stdio.h>
#include <stdlib.h>
int main()
{//online test, 3 questions
char capital;
printf("Question number 1: \n");
printf("What is the capital of Spain? \n");
scanf(" %s", &capital);
if(capital == "Madrid"){
printf("Correct, move on to question 2 \n");
}
if(capital != "Madrid"){
printf("Incorrect, start over");
}
return 0;
}
I am having a problem here, whenever i run the program it always gives me the answer "Incorrect, start over", how do i fix it so it displays correctly?
#include <stdlib.h>
int main()
{//online test, 3 questions
char capital;
printf("Question number 1: \n");
printf("What is the capital of Spain? \n");
scanf(" %s", &capital);
if(capital == "Madrid"){
printf("Correct, move on to question 2 \n");
}
if(capital != "Madrid"){
printf("Incorrect, start over");
}
return 0;
}
I am having a problem here, whenever i run the program it always gives me the answer "Incorrect, start over", how do i fix it so it displays correctly?