A solution without any if
#include <iostream>
bool equals(int val1, int val2, int val3, int val4)
{
return((val1 | val2 | val3 | val4) == (val1 & val2 & val3 & val4));
}
int main()
{
std::cout << "1, 1, 1, 1 -> " << (equals(1, 1, 1, 1)?"true":"false") << std::endl;
std::cout << "0, 0, 0, 0 -> " << (equals(0, 0, 0, 0)?"true":"false") << std::endl;
std::cout << "0, 0, 1, 1 -> " << (equals(0, 0, 1, 1)?"true":"false") << std::endl;
std::cout << "3, 3, 1, 1 -> " << (equals(3, 3, 1, 1)?"true":"false") << std::endl;
std::cout << "-5, -5, -5, -5 -> " << (equals(-5, -5, -5, -5)?"true":"false") << std::endl;
return(0);
}