/* Program to process exam grades - more modular version */ #include #include #include //needed to use exit() function using namespace std; const int SIZE = 50; int main() { int num,sum=0; int mark[SIZE]; double avgmark; //un-comment to redirect cin to a file //ifstream cin("c:\\bc\\CISC1110\\pgms\\chapter7\\myinput.txt"); cout << "Enter the number of marks: "; cin >> num; if (num > 0 && num <= SIZE) cout << endl << "There are " << num << " marks" << endl << endl; else { cout << "Invalid number of marks" << endl; // system("pause"); //un-comment when using DevC++ exit(1); } // enter marks and print them for (int count = 0; count < num; count++) { cout << "Enter a mark: "; cin >> mark[count]; cout << "mark[" << count << "]=" << mark[count] << endl; } // find the average mark for (int count = 0; count < num; count++) sum += mark[count]; avgmark = (double)sum/num; cout << endl << "The average is " << avgmark << endl; // system("pause"); //un-comment when using DevC++ return 0; }