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

  1. // C++ program to illustrate math assignment operators
  2.  
  3. #include <iostream.h>
  4.  
  5. main()
  6. {
  7.     int i, j;
  8.     double x, y;
  9.  
  10.     cout << "Type first  integer : ";
  11.     cin >> i;
  12.     cout << "Type second integer : ";
  13.     cin >> j;
  14.     i += j; 
  15.     j -= 6;
  16.     i *= 4;
  17.     j /= 3;
  18.     i++;   
  19.     j--;   
  20.     cout << "i = " << i << "\n";
  21.     cout << "j = " << j << "\n";
  22.  
  23.     cout << "Type first  real number : ";
  24.     cin >> x;
  25.     cout << "Type second real number : ";
  26.     cin >> y;
  27.     // abbreviated assignments also work with doubles in C++
  28.     x += y;
  29.     y -= 4.0;
  30.     x *= 4.0;
  31.     y /=  3.0;
  32.     x++;
  33.     y--;
  34.     cout << "x = " << x << "\n";
  35.     cout << "y = " << y << "\n";
  36.     return 0;
  37. }
  38.