Thread: C++ Help
View Single Post
Old 10-10-2012, 05:43 PM   PM User | #2
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,042
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
You didn't put the actual else ifs in. With your code each if statement is independent from each other. If you use your debug and step through your program line by line, you'd see what it is doing.

Code:
if (num1 == num2)
cout << "Exactly two of the numbers are the same." << endl;

else if (num2 == num3)
cout << "Exactly two of the numbers are the same." << endl;

else if (num1 == num3)
cout << "Exactly two of the numbers are the same." << endl;

else
cout << "None of the numbers are the same." << endl;
Your checks though are not sufficient in the event that all three numbers are the same. In addition you could consolidate all of the checks into one if statement using logical ORs.
__________________
OracleGuy
oracleguy is offline   Reply With Quote