// Ex431.cc // Sec. 4.3 of lecture // Alternative // Example: Heaviside function #include main() { double x,y; cout << endl << " Input Argument : "; cin >> x; // // Version a // y = 0.0 ; if ( x >= 0.0 ) y = 1.0 ; // genau eine Anweisung im if-Zweig cout << " Result of version a) : " << y << endl; // // Version b // if ( x >= 0.0 ) y = 1.0 ; else y = 0.0 ; cout << " Result of version b) : " << y << endl; // // Version c // if ( x >= 0.0 ) { y = 1.0 ; } else { y = 0.0 ; } cout << " Result of version c) : " << y << endl; // // Version d, Entscheidungsoperator // y = x >= 0 ? 1.0 : 0.0 ; cout << " Result of version d) : " << y << endl << endl; }