0

if/ else statement C++ help...

Why the if/ else statement is not working here? Please help :( int main() { int num1; int num2; cout << "Please enter an integer" << endl; cin >> num1; cout << "Please enter another interger" << endl; cin >> num2; cout << "num1 = " << num1 << " and num2 = " << num2 << endl; if (num1 == num2) cout << "The values are the same." << endl; cout << "Hey, that's a coincidence!" << endl; else cout << "The values are not the same" << endl; return 0; }

24th Mar 2017, 3:08 AM
Luke Mai
Luke Mai - avatar
1 Resposta
+ 2
There are a few things here. 1. #include <iostream> 2. using namespace std; 3. put your if statement in some braces/curly brackets {} or it could be that your misspelled integer in your second cout statement. :)
24th Mar 2017, 3:33 AM
JofS
JofS - avatar