// Program to test "istriangle" function. #include #include // has EXIT_SUCCESS, EXIT_FAILURE // Pre: 0 <= a <= b <= c. // Post: return value is true if a, b, c form sides of a right triangle, // false otherwise. bool istriangle(int a, int b, int c) { return (a*a + b*b == c*c); } int main(void) { int x, y, z; cout << "Enter three non-negative integers in non-decreasing order:\n"; cin >> x >> y >> z; if (!(0 <= x && x <= y && y <= z)) { cout << "Error! bad input.\n"; exit(EXIT_FAILURE); } cout << x << ", " << y << ", " << z; if (istriangle(x, y, z)) cout << " form a right triangle.\n"; else cout << " do not form a right triangle.\n"; return EXIT_SUCCESS; }