/* Program to process exam grades using an array */ #include #include 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\\cis1_5\\newpgms\\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"); exit(1); } // enter marks and find average mark for (int count = 0; count < num; count++) { cout << "Enter a mark: "; cin >> mark[count]; cout << mark[count] << endl; sum += mark[count]; } avgmark = (double)sum/num; cout << endl << "The average is " << avgmark << endl; system("pause"); return 0; }