//////////////////////////////////////////////////////////// // operator.cpp - how do I use the predefined operators? // //////////////////////////////////////////////////////////// #include #include using namespace std; // The predefined operators are a part of the language so // you don't need to include any libraries to use them. void main() { // the 2nd and 3rd statements below use two operators, // assignment "=" and times "*" int x; int y = 3; x = 2*(7-y); cout << "\n if y = 3, then x = 2*(7-y) = " << x << "\n"; // the statements below use the subscripting operators [] double a[3] = { 0.5, -2.333, 8.2e+3 }; cout << "\n a[] contains: "; cout << setw(8) << a[0] << setw(8) << a[1] << setw(8) << a[2] << "\n"; // the statement below uses assignment "=" and less "<" operators bool pred = (2 < 3); cout.setf(ios::boolalpha); cout << "\n the statement 2 < 3 is " << pred << "\n\n"; }