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

  1. // simple C++ program to illustrate simple math operations
  2.  
  3. #include <iostream.h>
  4.  
  5. main()
  6. {
  7.  
  8.     int int1, int2;
  9.     long long1, long2, long3, long4, long5;
  10.     float x, y, real1, real2, real3, real4;
  11.  
  12.     cout << "\nType first  integer : ";
  13.     cin >> int1;
  14.     cout << "Type second integer : ";
  15.     cin >> int2;
  16.     cout << "\n";
  17.     long1 = int1 + int2;
  18.     long2 = int1 - int2;
  19.     long3 = int1 * int2;
  20.     long4 = int1 / int2;
  21.     long5 = int1 % int2;
  22.     cout << int1 << " + " << int2 << " = " << long1 << '\n';
  23.     cout << int1 << " - " << int2 << " = " << long2 << '\n';
  24.     cout << int1 << " * " << int2 << " = " << long3 << '\n';
  25.     cout << int1 << " / " << int2 << " = " << long4 << '\n';
  26.     cout << int1 << " mod " << int2 << " = " << long5 << '\n';
  27.     cout << "\n\n";
  28.     cout << "Type first  real number : ";
  29.     cin >> x;
  30.     cout << "Type second real number : ";
  31.     cin >> y;
  32.     cout << "\n";
  33.     real1 = x + y;
  34.     real2 = x - y;
  35.     real3 = x * y;
  36.     real4 = x / y;
  37.     cout << x << " + " << y << " = " << real1 << '\n';
  38.     cout << x << " - " << y << " = " << real2 << '\n';
  39.     cout << x << " * " << y << " = " << real3 << '\n';
  40.     cout << x << " / " << y << " = " << real4 << '\n';
  41.     cout << "\n\n";
  42.     return 0;
  43. }
  44.