Hi,
I wrote the following program which can be compiled and built in Visual C++ compiler. However, it returned an error when I run the exe file.
Anyone could help?
Thanks
gogo
#include <iostream>
#include <string>
#include <cctype>
#include <iomanip>
using namespace std;
int main()
{
const int MAX = 10;
string name[MAX] = {0};
int mark[MAX] = {0};
int count = 0;
int sum = 0;
float average = 0;
char finish = 'n';
do
{
cout << "Enter your name : ";
cin >> name[count++];
cout << endl;
cout << "Enter your mark : ";
cin >> mark[count++];
sum += mark[count++];
cout << endl;
cout << "Do you want to add more ? ";
cin >> finish;
} while (tolower(finish)=='y' && (count < MAX));
average = sum / count;
cout << endl;
cout << "The average mark is : " << average << ".\n";
cout << endl;
cout << "Student Name" << setw(5) << "Marks";
cout << "____________" << setw(5) << "_____";
cout << endl;
cout << endl;
for (int i=0; i< count; i++)
cout << name[i] << setw(8) << mark[i] << endl;
return 0;
}