So this is for school, and it's supposed to get 3 numbers from the input and output if no numbers are the same, 2 numbers are the same, or all the numbers are the same. I know I'm supposed to use an else if statement but not sure really how to do it. Here's what I have so far
Quote:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int num1, num2, num3;
// Get User Input
cout << "Please enter the first number (an integer): ";
cin >> num1;
cout << "Please enter the second number (an integer): ";
cin >> num2;
cout << "Please enter the third number (an integer): ";
cin >> num3;
cout << endl;
// Go Program Go!
if (num1 == num2)
cout << "Exactly two of the numbers are the same." << endl;
if (num2 == num3)
cout << "Exactly two of the numbers are the same." << endl;
if (num1 == num3)
cout << "Exactly two of the numbers are the same." << endl;
else
cout << "None of the numbers are the same." << endl;
cout << endl;
return 0;
}
|
It's displaying both couts, what's causing the else to output?