Final answer:
To determine whether two, three, or all four numbers entered by the user are equal and to find the greatest number, you can use a C++ program with compound if statements. The program compares each number and uses logical operators to make the necessary comparisons. The result is then printed using cout.
Step-by-step explanation:
To write a program in C++ that determines whether two, three, or all four numbers entered by the user are equal, as well as which one is the greatest, you can use compound if statements. Here is an example code:
#include<iostream>
using namespace std;
int main() {
int num1, num2, num3, num4;
cout << "Enter four numbers: ";
cin >> num1 >> num2 >> num3 >> num4;
if (num1 == num2 && num2 == num3 && num3 == num4) {
cout << "All numbers are equal." << endl;
}
else if (num1 >= num2 && num1 >= num3 && num1 >= num4) {
cout << "The greatest number is " << num1 << endl;
}
else if (num2 >= num1 && num2 >= num3 && num2 >= num4) {
cout << "The greatest number is " << num2 << endl;
}
else if (num3 >= num1 && num3 >= num2 && num3 >= num4) {
cout << "The greatest number is " << num3 << endl;
}
else {
cout << "The greatest number is " << num4 << endl;
}
return 0;
}