I am trying to make a quiz using functions, but for some reason even if the answer is correct, i get an incorrect message. Does someone see where the mistake in my program is?
#include <iostream>
#include <string>
usingnamespace std;
void question(string a, string b)
{
cin >> a;
getline(cin,a);
if(a == b)
cout << "Correct!" << endl;
if (a != b)
cout<< "Incorrect! The correct answer is: " << b << endl;
}
int main()
{
string a;
cout << "What is the capital city of Belgium? ";
string b = "Brussels";
question(a,b);
cout << "What is the capital of the US? ";
b = "Washington";
question(a,b);
cout << "What is the capital city of Great Britain? ";
b = "London";
question(a,b);
}