stealth75711
March 7th, 2007, 03:59 AM
#include <iostream>
using namespace std;
int main()
{
int numStudents,
numTests,
total;
double average;
cout<<"This program averages test scores.\n";
cout<<"For how many students do you have test scores? ";
cin >> numStudents;
cout<<"How many test scores does each student have? ";
cin >> numTests;
for (int student = 1; student <= numStudents; student++)
{
total = 0;
for (int test = 1; test <= numTests; test++)
{
int score;
cout<< "Enter score " <<test<< " for ";
cout<<"student " << student << ": ";
cin >> score;
total += score;
}
average = total / numTests;
cout << "The average score for student " << student;
cout << " is" <<average<< ". \n\n";
}
return 0;
}
// When i go to compile it via the terminal i get this error
g++ testscores.cpp -o testscores
testscores.cpp:36:3: warning: no newline at end of file
// Anyone know whats wrong?
using namespace std;
int main()
{
int numStudents,
numTests,
total;
double average;
cout<<"This program averages test scores.\n";
cout<<"For how many students do you have test scores? ";
cin >> numStudents;
cout<<"How many test scores does each student have? ";
cin >> numTests;
for (int student = 1; student <= numStudents; student++)
{
total = 0;
for (int test = 1; test <= numTests; test++)
{
int score;
cout<< "Enter score " <<test<< " for ";
cout<<"student " << student << ": ";
cin >> score;
total += score;
}
average = total / numTests;
cout << "The average score for student " << student;
cout << " is" <<average<< ". \n\n";
}
return 0;
}
// When i go to compile it via the terminal i get this error
g++ testscores.cpp -o testscores
testscores.cpp:36:3: warning: no newline at end of file
// Anyone know whats wrong?