#include <iostream>
#include <string>
usingnamespace std;
int main()
{
int numstudents;
cout << "Enter the class size: ";
cin >> numstudents;
string first, last;
string names[numstudents];
int marks[numstudents];
for (int i = 0; i < numstudents; i++) {
cout << "Enter a student's name: ";
cin >> first >> last;
names[i] = string(first) + string(" ") + string(last);
cout << "Enter " << names[i] << "'s mark: ";
cin >> marks[i];
}
cout << "\n\nStudents:" << endl;
for (int j = 0; j < numstudents; j++) {
cout << " Name: " << names[j] << endl;
cout << " Mark: " << marks[j] << endl;
}
return 0;
}
I know this isn't necessarily the best way to do this, as you can use getline() or cin.getline(), but I haven't yet figured those out completely. I don't want you to just copy this though. If you don't understand or have any questions, please say so!
Dream on trojansdestroy. Posters that just cut and paste the problem, also just cut and paste the (your) answer. If you want to help, help them work through it. But don't post complete solutions. ;-)