// Comparison of passing by value and by reference
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

// prototypes
int  bacteriaGrowthbyValue(int, double);
void bacteriaGrowthbyRefer(int, double, int&);

int main() {

  int n, m;

  n = bacteriaGrowthbyValue(100, 3600.*6.);
  cout << "Number of bacteria = " << n << endl;

  // m is passed by reference
  bacteriaGrowthbyRefer(100, 3600.*6., m);
  cout << "Number of bacteria = " << m << endl;

}

// a function with values passed by value
int bacteriaGrowthbyValue(int    initialBacteria,
                          double growthTime)
{
  const double growthRate = 2.8e-4;
  return int(initialBacteria*exp(growthRate*growthTime));
}

// a function with a value passed by reference
void bacteriaGrowthbyRefer(int    initialBacteria,
                           double growthTime,
                           int    &bacteria)
{
  const double growthRate = 2.8e-4;
  bacteria = int(initialBacteria*exp(growthRate*growthTime));
}
