// This program is a modification of our earlier program runtime.cpp. // This sends a warning message to the user if data are entered that // will lead to a runtime error. It illustrates the use of the if // statement. Make sure you use == instead of = to test equality in // an if statement. #include #include void main() { int a,b; double x,y,z; cout << "Enter 2 integers: "; cin >> a >> b; x = 1./(a-b); if (a==b) cout << "Next time, enter two DISTINCT integers." << endl; cout << "1/(" << a << " - " << b << ") = " << x << endl; cout << "Enter a real number: "; cin >> y; if (y<0) cout << "Next time, enter a NONNEGATIVE real number." << endl; z = sqrt(y); cout << "The square root of " << y << " is " << z << endl; }