0

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;
}
}

Edited by WaltP: Added CODE tags -- with all the help about them, how could you miss using them????

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Nick Evan
0
  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.

Edited by Dani: Formatting fixed

0
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];
}

Edited by necrolin: n/a

1

1) Use code tags,

/* put code here */ 
[code]

[/QUOTE] 

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

[/noparse]

Votes + Comments
Indeed. Even some of the moderators seem to give quite unclear instructions on how to use these so-hard-to-get-right code tags.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.