home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tybc4 / for4.cpp < prev    next >
C/C++ Source or Header  |  1993-03-22  |  733b  |  34 lines

  1. // Program that demonstrates using the continue statement
  2. // to skip iterations.
  3.  
  4. #include <iostream.h>
  5. #include <math.h>
  6.                                     
  7.                                     
  8. double f(double x)
  9.   return sqrt(x * x - 9);
  10. }
  11.                                     
  12. main()
  13. {
  14.    double x, y;
  15.  
  16.    cout << "        X";
  17.    cout << "          f(X)\n";
  18.    cout << "_________________________________\n\n";
  19.    // for loop with empty parts
  20.    for (int i = -10; i <= 10; i++) {
  21.      if (i > -3 && i < 3)
  22.        continue;
  23.      x = (double)i;
  24.      y = f(x);
  25.      cout << "      ";
  26.      cout.width(3);
  27.      cout << x << "        ";
  28.      cout.width(7);
  29.      cout << y << "\n";
  30.    }
  31.    return 0;
  32. }
  33.