24: Write a program that takes three integer inputs from the user, and then checks if any two of them are equal. If so, the program should print out "Two numbers are equal" otherwise, it should print "All numbers are different".
// Write a program that takes three integer inputs from the user,
// and then checks if any two of them are equal.
// If so, the program should print out "Two numbers are equal" otherwise,
// it should print "All numbers are different".
#include <iostream>
using namespace std;
int main()
{
int numa, numb, numc;
cout << "Enter the first integer: ";
cin >> numa;
cout << "Enter the second integer: ";
cin >> numb;
cout << "Enter the third integer: ";
cin >> numc;
if (numa == numb && numa == numc)
{
cout << "All three integers are equal \n";
}
else if (numa == numb || numb == numc || numc == numa)
{
cout << "Two numbers are equal \n";
}
else
cout << "All integers are unequal \n";
return 0;
}
Comments
Post a Comment