// Program file: iftest.cpp // Demonstrates the use of if statements #include #include #include using namespace std; void enter_data(int &a, int &b, int &c, int &d); int if_function(int a, int b, int c, int d); void display_result(int r); int main() { int a, b, c, d, r; enter_data(a, b, c, d); r = if_function(a, b, c, d); getch(); display_result(r); system("pause"); return 0; } int if_function(int a, int b, int c, int d) { int r = 0; if (a > b) { r = a; if (a < c) { r += c; } else { if (b == d) { r += d; if (c > d) r += b; else r += d; } else r += 4; r += 5; } } else if (a >= c) r += 6; else r += 7; return r; } void enter_data(int &a, int &b, int &c, int &d) { cout << "Enter the value for 'a': "; cin >> a; cout << "Enter the value for 'b': "; cin >> b; cout << "Enter the value for 'c': "; cin >> c; cout << "Enter the value for 'd': "; cin >> d; } void display_result(int r) { cout << "The final value for 'r' is: " << r << endl; }