home *** CD-ROM | disk | FTP | other *** search
/ Microsoftware Monthly 19…2 Programming Power Tools / MASO9512.ISO / cpptutor / cpptutor.arj / EXAMPLES / EX0421.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-27  |  674 b   |  25 lines

  1. // \EXAMPLES\EX0421.CPP
  2. // This is not an example of a preferred programming style.
  3. // It is just an example of using labels.
  4. #include <iostream.h>
  5.  
  6. const int size = 3;
  7.  
  8. int num[size][size] = {{2, 2, 4},
  9.                        {3, 4, 5},
  10.                        {1, 0, 2}};
  11.  
  12. void main() {
  13.    for (int i = 0; i < size; i++) {
  14.       for (int j = 0; j < size; j++) {
  15.          if ( num[i][j] == 0)
  16.             goto div_zero;              // get out of both loops
  17.          cout << "Result is :" << num[j][i]/ num[i][j] << endl;
  18.       }
  19.    }
  20.    goto END;
  21.    div_zero:  cout << "incomplete"      // print error message
  22.                    << endl;
  23.    END:;
  24. }
  25.