bartBorzeckiLabWeek6

bartBorzeckiLabWeek6 - Bart Borzecki Lab7 December 5, 2008...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Bart Borzecki Lab7 December 5, 2008 Prof. Gross 7.1 Code // This program will read in a group or test scores (positive integers from 1 to 100) // from the keyboard and then calculate and output the average score // as well as the highest and lowest score. There will be a maximum of 100 scores. // Bart Borzecki #include <iostream> using namespace std; typedef int GradeType[100]; // declares a new data type: // an integer array of 100 elements float findAverage ( const GradeType, int ); // finds average of all grades int findHighest ( const GradeType, int ); // finds highest of all grades int findLowest ( const GradeType, int ); // finds lowest of all grades int main() { GradeType grades; // the array holding the grades. int numberOfGrades; // the number of grades read. int pos; // index to the array. float avgOfGrades; // contains the average of the grades. int highestGrade; // contains the highest grade. int lowestGrade; // contains the lowest grade. // Read in the values into the array pos = 0; cout << "Please input a grade from 1 to 100, (or -99 to stop)" << endl; cin >> grades[pos]; while (grades[pos] != -99) { pos++; cout << "Please input a grade from 1 to 100, (or -99 to stop)" << endl; cin >> grades[pos]; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Lab7 December 5, 2008 Prof. Gross numberOfGrades = pos; // call to the function to find average avgOfGrades = findAverage(grades, numberOfGrades); cout << endl << "The average of all the grades is " << avgOfGrades << endl; highestGrade = findHighest(grades, numberOfGrades); cout << endl << "The highest grade is " << highestGrade << endl; lowestGrade = findLowest(grades, numberOfGrades); cout << endl << "The lowest grade is " << lowestGrade << endl; return 0; } //*************************************************************************** ***** // findAverage // // task: This function receives an array of integers and its size. // It finds and returns the average of teh numbers in the array // data in: array of floating point numbers // data returned: average of the numbers in the array // //*************************************************************************** ***** float findAverage ( const GradeType array , int size) { float sum = 0; // holds the sum of all the numbers for ( int pos = 0; pos < size; pos++) sum = sum + array [pos]; return (sum / size); // returns the average } //*************************************************************************** ***** // findHighest // // task: This function receives an array of integers and its size. // It finds and returns the highest value of the
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/06/2011 for the course CIS 115 taught by Professor Leipus during the Spring '08 term at DeVry Tinley Park.

Page1 / 11

bartBorzeckiLabWeek6 - Bart Borzecki Lab7 December 5, 2008...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online