# Array; program that calculates average and finds highest and lowest sc

Page 1 of 1

## 2 Replies - 2166 Views - Last Post: 22 February 2011 - 01:57 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=217977&amp;s=266f5979cd7acd0fa8ccc768f17e42a1&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Ness69

Reputation: 0
• Posts: 32
• Joined: 27-January 11

# Array; program that calculates average and finds highest and lowest sc

Posted 22 February 2011 - 01:45 PM

```//This program records tests scores for a teacher that wants to find the highest, lowest and the average score.

//Amehd Gutierrez

#include <iostream>
using namespace std;

int main()
{
const int Test_scores = 20;		// number of students that took test
int testscores[Test_scores];	//Scores of the students
int count;

//input for the test scores
for (count = 0; count < Test_scores; count++)
{
cout << "Enter score " << (count + 1) << ": ";
cin >> testscores[count];

}

//calculates the average
double total = 0;		//initialize accumalator
double average;			//will hold the averag
for (int count = 0; count < Test_scores; count++)
total+= testscores[count];
average = total / Test_scores;

//finds the highest score
int count;
int highest;

highest = testscores[0];
for (count = 1; count < Test_scores; count++)
{
if (testscores[count] > highest)
highest = testscores[count];
}

//finds the lowest score
int count;
int lowest;

lowest = testscores[0];
for (count = 1; count < Test_scores; count++)
{
if (testscores[count] < lowest)
lowest = testscores[count];
}

//Diplays the highest,lowest and average score
cout << "The lowest score is " << lowest << endl;
cout << "The highest score is " << highest << endl;
cout << "The average score is " << average << endl;

return 0;
}

```

So i typed up this c++ program for my an assignment. i need help with compiling. i believe the program works but does not want to compile and i doesnt want to show my lowest highest and average scores. any suggestions?

Is This A Good Question/Topic? 0

## Replies To: Array; program that calculates average and finds highest and lowest sc

### #2 diego_pmc

Reputation: 83
• Posts: 565
• Joined: 13-May 09

## Re: Array; program that calculates average and finds highest and lowest sc

Posted 22 February 2011 - 01:51 PM

What errors do you get during compilation?

### #3 Ness69

Reputation: 0
• Posts: 32
• Joined: 27-January 11

## Re: Array; program that calculates average and finds highest and lowest sc

Posted 22 February 2011 - 01:57 PM

has to do with the int count

i got it! lol i was declaring int count 3x.