// july29ex2.cpp : Defines the entry point for the console application.
// Create random gpas for 1000 students.
//print out the number of students for each gpa (at least those > 0)
// find out the most popular gpa(s)

#include "stdafx.h"
#include "stdlib.h"
#include "time.h"

int main(int argc, char* argv[])
{   int gpa_cnt [401] = {0};    /* Will hold gpas 0.00 -> 4.00 in positions 0 -> 400 */

    int gpa, maxgpa=-1, stu;
	
	srand(time(NULL));

	for (stu=1; stu<=1000; stu++) {
        gpa= rand() % 401;   /* gives num 0 thru 400 */

		gpa_cnt [gpa]++;


	} /* end for stu */


	for (gpa=0; gpa<= 400; gpa++) 
		if (gpa_cnt[gpa] > 0) {
			printf("GPA of %4.2f had count of %d \n", gpa/100.00, gpa_cnt[gpa] );
			if (gpa_cnt[gpa] > maxgpa)
				 maxgpa = gpa_cnt[gpa];

		} /* end if gpa_cnt */

	printf("\nThe max count was %d found at gpa(s) ", maxgpa);

	for (gpa=0; gpa<= 400; gpa++) 
		if (gpa_cnt[gpa] == maxgpa)
			printf("%4.2f ", gpa/100.00);

	return 0;
}