Input to an addition problem
So I just started out with C++ and using Visual C++ Express 2008 and I am following the starter tutorials on the site and one the second lesson. I would rewrite the code and change it so I can make sure I know. But I am completly stuck on one thing, I know that this was not in the lesson, but I tried it anyway and it failed, but I won't go on until I know this.
I want to put the input for an answer of a + b, but I am not sure how to put. I knew cin<< a + b; wouldn't work but I tried anyways. Anyone can help me, or if you think is better and I should see a specific lesson.
Code:
#include <iostream>
using namespace std;
int main()
{
int a , b, c, d;
cout<<"I am going to test you! Just put random numbers, don't fail now!";
cin.ignore();
cout<<"Your first number: ";
cin>> a;
cin.ignore();
cout<<"Your second number: ";
cin>> b;
cin.ignore();
cout<<"Your third number: ";
cin>> c;
cin.ignore();
cout<<"Your forth number: ";
cin>> d;
cin.ignore();
cout<<"Q1 - What is "<< a <<" plus "<< b <<"\n";
cin>> a + b ;
if ( a + b == a + b ) {
cout<<"Good, next question.";
}
else { cout<<"You FAILED, NOW GTFO!!";
}
cin.get();
}
The code is not done for sure.