/* This version of runtime.ccp uses a do while loop to force the user to enter data which will not lead to a runtime error. */ #include #include void main() { int a,b; double x,y,z; do { cout << "Enter two distinct integers: "; cin >> a >> b; } while (a == b); // At this point we know that a != b. x = 1./(a-b); cout << "1/(" << a << " - " << b << ") = " << x << endl; do { cout << "Enter a nonnegative real number: "; cin >> y; } while (y<0); // At this point we know that y >= 0. z = sqrt(y); cout << "The square root of " << y << " is " << z << endl; }