// Example of for loops to compute a limit. // limit.cpp // ESC 104 #include #include #include main() { float limit; float x; float delta_x; float a,b,c,d,e,f,x0; int i; cout << setprecision(2) << setiosflags( ios::fixed | ios::showpoint ); cout << "Enter a: "; cin >> a; cout << "Enter b: "; cin >> b; cout << "Enter c: "; cin >> c; cout << "Enter d: "; cin >> d; cout << "Enter e: "; cin >> e; cout << "Enter f: "; cin >> f; cout << "Enter x0: "; cin >> x0; cout << "\n( " << a << "x^2 + " << b << "x + " << c << ")/" << "( " << d << "x^2 + " << e << "x + " << f << ") \n" << endl; cout << "Press any key to compute limit as x --> " << x0 << "\n"; getch(); cout << setprecision(5) << setiosflags( ios::fixed | ios::showpoint ); for( i=200; i>1; i--) { delta_x = (float)i/1000; x = x0 + delta_x; limit = ( a*x*x + b*x + c ) / ( d*x*x + e*x + f ); cout << "Limit at x = " << x << " is " << limit << endl; } return 0; }