I want it to not display the result of the sum if the numbers are lower or equal to 1 or 1000. I don't know if using if
is the best way, but that's what I tried using, and I don't really understand why it doesn't work. I also tried writing conditions with ||
and &&
, but those don't work either.
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int sum;
int a, b, c;
int main() {
cin >> a;
cin >> b;
cin >> c;
sum = a + b + c;
if ( 1 <= a, b, c <= 1000) { //also tried ( 1 <= a || b || c <= 100) and ( a, b, c >= 1 && a, b, c <= 1000)
cout<< sum;
}
else {
cout<< "can't calculate";
}
return 0;
}