Hey guys,I need someone to inform me what I'm doing wrong. I'm trying to add inputted test scores inside of a loop to get an average. My problem is, the program will not add all of the inputted scores. It only adds the last number plus itself.
Thank you.
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main ()
{
int scores, total, test, average, start=1;
string name;
cout << "Please enter your name: ";
cin >> name;
cout << "How many test scores do you have: ";
cin >> scores;
while (start <= scores)
{
cout << "Please enter your score for test " << start++ << endl;
cin >> test;
total = test + test;
}
average = total / scores;
cout << "The test average for " << name << " is " << average;
Ahhh, count=count+1... Thanks for catching that, that worked! I appreciate you taking the time to answer my question. Now i need to remember to use the += operator.