Write a program that will read in 10 test scores. Print out all 10 scores, then print the highest score, and then the lowest score.

Ok i got this so far but i do not know how to print the highest or lowest.

#include<iostream>
using namespace std;
int main()
{
int score;
int t[10];
while(cin >> t[10])
{
cout << t[10] << endl;
}
}

Recommended Answers

All 3 Replies

  1. Use code tags, [code ] /* put code here */ [code]
  2. You code is not doing what you think it is doing.
  3. To make it do what you think its doing, you need to use loop(s).
  4. Create a min and max variable. Whenever the user enters a number
    update the min and max variable so that it points to the correct value.
int t[10];
while(cin >> t[10])

Be careful. You declare an array of size 10. This will begin at t[0] and go up to t[9]. You're trying to put data into location t[10] which isn't part of the array. This may crash your program.

What I assume you want to do is to enter 10 integers into the array. To do this use a for loop like this:

for (int i = 0; i < 10; i++)
{
    cout << "Enter next integer: "; //Don't really need this line
     cin >> t[i];
}

1) Use code tags,

/* put code here */ 
[code]

[/QUOTE] 

Small correction here:
[noparse]
[code]
 /* put code here */

[/noparse]

commented: Indeed. Even some of the moderators seem to give quite unclear instructions on how to use these so-hard-to-get-right code tags. +5
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.