// Mr. Minich
// CMPSC 101
// Ch. 3 Demo Program #3
// January 30, 2000 // Purpose - to illustrate the use of functions.

#include <iostream>
using namespace std; double gradeCurvingFunction(double studentGrade, int curveAmount); // Technically parameter names do not have to be specified in a function // prototype, only the data types. The following function prototype // would also work, // double gradeCurvingFunction(float, int); double gGlobalGrade = 0; // this is dangerous! // NEVER declare variables above/outside of the main function. // If you do, you had better have a good reason for using what // is called a "global variable". Global variables should be named
// so that they begin with a lowercase 'g'.
int main() { int curveAmount = 0; // the amount of increase cout << "Enter the students grade percentage: "; cin >> gGlobalGrade; cout << "Enter a curve amount of 1, 2, 3 or 4: "; cin >> curveAmount; cout << "Your new grade is " << gradeCurvingFunction(gGlobalGrade, curveAmount) << endl; // A function that returns a value can be used within a // cout statement. return 0; } // end of main double gradeCurvingFunction(double grade, int amount) { // This function increases a student's grade by a specified // amount of percentage points. // Technically the parameter identifiers grade and amount do not have // to be the same ones that are used in the function prototype return (grade + amount); } // end of gradeCurvingFunction