0

Hello,
I've been taking a class on C++, and the summer semester is now over but I'm very interested in taking more classes during the fall. I've ran into a few problems here and there. I have a few questions about functions. How would I write a function that takes the highest number in an array of 10 and out put it? And a function that sorts from highest to lowest?
Here is what I have so far, can anyone tell me what I've done wrong? (this is the highest number function problem that I've ran into in that past)

#include <iostream>

using namespace std;
double max()
{
      int max = (i = 0; i < number; i++);
}
  int main()
  {
    int number[12];
    int i;
    i = 1;    
    while( i < 12 )
    {
      cout << "What is the number " << i << " ";
      cin >> number[i]; 
    
    }
    i = 1;          
    int max = 0;  
    while( i < 10 )
    {
      max += number[i];
   
    }
    cout << "The Highest number is "
         << max << endl;  
cin.get();
cin.ignore();
}
2
Contributors
1
Reply
2
Views
12 Years
Discussion Span
Last Post by Narue
0

>And a function that sorts from highest to lowest?
That's a very broad question. You can look here for an idea of where you want to go with it.

>How would I write a function that takes the highest number in an array of 10 and out put it?
Conveniently enough, this is an example in the first part of the tutorial linked to above. ;)

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.