// operating with variables

#include <iostream>
#include <cmath>
using namespace std;

int main (){
  int a=0,b=-1; // can fill with initial values
  int result;

  double c,d;   // don't need to fill with initial values if you don't want to
  double result_double;

  //******************************************************************************
  // now do integer arithmetic, double arithmetic, and mixed integer double
  // arithmetic
  //******************************************************************************
  cout << "\n";
  cout << "\n";
  cout << "Do calculations with integers, and store the result in an integer\n";
  a = 6;
  b = 2;
  a = a + 1;
  cout << "a is integer " << a << "\n";
  cout << "b is integer " << b << "\n";
  result = b/a;
  cout << "b/a " << result << "\n";
  result = a/b;
  cout << "a/b " << result << "\n";

  cout << "\n";
  cout << "Do calculations with doubles, and store the result in a double\n";
  c = 7;
  d = 2;
  cout << "c is double " << c << "\n";
  cout << "d is double " << d << "\n";
  result_double = d/c;
  cout << "d/c " << result_double << "\n";
  result_double = c/d;
  cout << "c/d " << result_double << "\n";

  cout << "\n";
  cout << "Do calculations with mixed integers and doubles, and store the result in a double\n";
  cout << "\n";
  cout << "c is double  " << c << "\n";
  cout << "b is integer " << b << "\n";
  result_double = b/c;
  cout << "b/c " << result_double << "\n";
  result_double = c/b;
  cout << "c/b " << result_double << "\n";

  cout << "\n";
  cout << "Do calculations with mixed integers and doubles, and store the result in an integer\n";
  cout << "a is integer " << a << "\n";
  cout << "d is double  " << d << "\n";
  result = d/a;
  cout << "d/a " << result << "\n";
  result = a/d;
  cout << "a/d " << result << "\n";
  
  //******************************************************************************
  // try some built-in math functions in cmath
  //******************************************************************************
  cout << "\n";
  cout << "Log of -a is  " << log(-a) << endl;
  cout << "Log of 0 is   " << log(0) << endl;
  cout << "Log of +a is  " << log(+a) << endl;
  cout << "Pi is         " << acos(-1.0) << endl;
  cout << "Sin of +a is  " << sin(+a) << endl;
  cout << "c^2 is        " << pow(+c,2) << endl;
  cout << "c^1.5 is      " << pow(+c,1.5) << endl;
  cout << "a modulo b is " << a%b << endl;           // won't compile with anything other than integers
  cout << "c modulo d is " << fmod(c,d) << endl;       
  cout << "exp(c) is     " << exp(c) << endl;
  cout << "abs(log(1/a)) " << abs(log(1/a)) << endl; // Unexpected result?
  cout << "abs(log(1/c)) " << abs(log(1/c)) << endl;

  cout << "\n";

  return 0;
}
