/*
Write a function with an input s of type string and that returns 
the number of lowercase letters in s and the number of uppercase 
letters in s. 
*/

/*
Remarks: 
- Reference parameters are proceeded by & (ampersand).
- Unlike value parameters, if a function changes the value of the reference parameter, 
  the value of the corresponding argument will change immediately.
- The arguement corresponding to a reference parameter must be a variable, 
  while the argument corresponding to a value parameter can be a variable, 
  a literal constant, a named constarnt, or an expression.
- Reference parameters can be input parameters (i.e. they receive values 
  from the caller via the corresponding argument) and output parameters 
  (i.e. they return a value to the caller via the corresponding argument
  by changing its value, while value parameters are input parameters only.

*/

#include <iostream>
#include <string>
using namespace std;

// Function prototype
void case_count(string, int&, int&);

int main() 
{
	string t;
	int l, u;
	cout << "Enter a string: " << endl;
	getline(cin,t);
	case_count(t,u,l);
	cout << "The string has " << u << " uppercase letters and "
			<< l << " lowercase letters.\n";
	return 0; 
}

// Definition of function
void case_count(string s /*value parameter*/, 
int& upper_count /*reference parameter*/, 
int& lower_count /*reference parameter*/)
{
	int i;
	upper_count = 0;
	lower_count = 0;
	for (i = 0; i < s.size(); i++)
		if (isupper(s[i]))
			upper_count++;
		else if (islower(s[i]))
			lower_count++;
}
