2 Replies - 2139 Views - Last Post: 22 February 2011 - 01:57 PM Rate Topic: -----

#1 Ness69   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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   User is offline

  • D.I.C Addict

Reputation: 83
  • View blog
  • 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?
Was This Post Helpful? 0
  • +
  • -

#3 Ness69   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1