Quote:
|
I don't think a book is required.
|
While what you say is technically true in this instance, especially in light of the fact he will probably have a book in his college classes, that is horrible advice in general. Tutorials and online references are fine for a superficial level of understanding, which would more than likely suffice in this situation, but it's a bad habit to get into. I'm not suggesting that online info is worthless because it's not. It has its place and so do books.
Quote:
|
So what I want to do is make the answer to the question "Six" instead of 6. Other answers will need more than one word for an answer.
|
You're on the right track, but first you should know that there is more than one way to accomplish your task. I would use a string (making sure to include <string>) and the 'getline' function. Modifying your code:
Code:
#include <iostream>
#include <string>
using namespace std;
int main(){
string q1;
cout << "How many years does a senator serve in Congress? ";
getline(cin, q1);
if (q1 == "six years")
cout << "That is correct!";
else
cout << "That is incorrect!";
system("PAUSE");
return 0;
}