#include #include using namespace std; int main() { /* * Bank Example */ cout << endl << "Bank Example" << endl; const int WITHDRAWAL = 0; const int DEPOSIT = 1; const int TRANSFER = 2; const float MAX_WITHDRAWAL = 500.0; double balance1 = 100.0; double balance2 = 200.0; /* * Equivalent to If / Else */ cout << endl << "Equivalent to If / Else" << endl; int transaction = DEPOSIT; double amount = 250.0; cout << "\nDeposit Example" << endl; cout << "balance1: " << balance1 << endl; cout << "depositing: " << amount << endl; transaction == DEPOSIT ? balance1 = balance1 + amount : balance1 = balance1 - amount; cout << "New balance1: " << balance1 << endl; getch(); /* * Conditional Operators Return Value */ cout << endl << "Conditional Operators Return Value" << endl; transaction = WITHDRAWAL; amount = 50.0; cout << "\nWithdrawal Example" << endl; cout << "balance2: " << balance2 << endl; cout << "withdrawing: " << amount << endl; balance2 = transaction == DEPOSIT ? balance2 + amount : balance2 - amount; cout << "New balance2: " << balance2 << endl; getch(); }