/* Craig Persiko
   calcDemo.cpp
   Demonstrates how variables and data types work in calculations
*/

#include <iostream>

using namespace std;

int main()
{
  int i1 = 11, i2 = 4;
  double d1 = 9.5, d2 = 4;

  cout << "Using numeric literals:\n";
  cout << "2/3 equals: " << 2/3 << endl;
  cout << "2.0/3 equals: " << 2.0/3 << endl;

  cout << "\nUsing integer variables:\n";
  cout << i1 << " * " << i2 << " equals " << i1 * i2 << endl;
  cout << i1 << " / " << i2 << " equals " << i1 / i2 << endl;
  cout << i1 << " % " << i2 << " equals " << i1 % i2 << endl;

  cout << "\nUsing floating-point (double) variables:\n";
  cout << d1 << " * " << d2 << " equals " << d1 * d2 << endl;
  cout << d1 << " / " << d2 << " equals " << d1 / d2 << endl;
  
  cout << "\nUsing a mix of both types of numeric variables:\n";
  cout << i1 << " * " << d1 << " equals " << i1 * d1 << endl;
  cout << i1 << " / " << d2 << " equals " << i1 / d2 << endl;
  
  /* Modulus only works with integers.  When I included this line:
  
  cout << d1 << " % " << i2 << " equals " << d1 % i2 << endl;
  
  I got this error:
  
  calcDemo.cpp:31: error: invalid operands of types ‘double’ and ‘int’ to binary ‘operator%’
  */
  
  return 0;
}
  
/* Compilation and Output on Linux:

[cpersiko@localhost cs110aF2F]$ g++ calcDemo.cpp
[cpersiko@localhost cs110aF2F]$ ./a.out
Using numeric literals:
2/3 equals: 0
2.0/3 equals: 0.666667

Using integer variables:
11 * 4 equals 44
11 / 4 equals 2
11 % 4 equals 3

Using floating-point (double) variables:
9.5 * 4 equals 38
9.5 / 4 equals 2.375

Using a mix of both types of numeric variables:
11 * 9.5 equals 104.5
11 / 4 equals 2.75
[cpersiko@localhost cs110aF2F]$ 

*/


syntax highlighted by Code2HTML, v. 0.9