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

>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. ;)

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.