In this article I would like to share with you a sample program that I wrote for my class in C++ programming 6 years ago to check and determine the grade brackets of the students using two dimensional array in C++. The code is very simple and easy to understand I hope you will find my work useful in learning C++ programming.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Program Listing
#include <iostream>
using namespace std;
main()
{
double grades[5][2];
int row=0,col=0, count=0, count2=0;
int count3=0, count4=0;
cout << "\t Grade Bracket Version 1.0 ";
cout << "\n\n";
// Ask for 10 grades
for(row= 0 ; row < 5 ; row++){
for (col=0; col <2; col++) {
cout<< "Enter grades :=>";
cin >> grades[row][col];
}
}
for(row= 0 ; row < 5 ; row++){
for (col=0; col <2; col++) {
if(grades[row][col] >= 90){
count++;
}
if(grades[row][col] >= 80 && grades[row][col] <90)
{
count2++;
}
if(grades[row][col] >= 75 && grades[row][col] < 80)
{
count3++;
}
if(grades[row][col] < 75)
{
count4++;
}
}
}
//display
cout << "\n====================";
cout << "\n RESULTS ";
cout << "\n====================";
cout << "\n\n";
cout<<"\nGrades >=90 is: " <<count;
cout<<"\nGrades 80 - 89 is: " <<count2;
cout<<"\nGrades 75 - 80 is: " <<count3;
cout<<"\nGrades < 75 is: " <<count4;
cout << "\n\n";
system("pause");
}