an array named slopes

I am having trouble writing a program that uses a array declaration statement to initialize the following number in an array named slopes : 17.24, 25.63, 5.94, 33.92, 3.71, 32.84, 35.93, and 6.92 that also displays the max and min values in thee array.
if anyone can help me and explain it thanks!!
Arrays - including declaration with values:
http://www.cplusplus.com/doc/tutorial/arrays/

Think how you mentally calculate max or min and then look up for ( ) loops:
http://www.cplusplus.com/doc/tutorial/control/

Then show us your code.
thanks ill get back to you !
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include<iostream>
using namespace std;
int main()
{
   float slopes[8]={17.24, 25.63, 5.94, 33.92, 3.71, 32.84, 35.93, 18.24, 6.92};
   float max,min;
   max=slopes[0];
   min=slopes[0]; 
   for(int i=0;i<9;i++) 
   {
       if(slopes[i]<min) 
           min=slopes[i]
       if(slopes[i]>max) 
           max=slopes[i]
   }
   cout<<"Max element is :"<<min<<endl;
cout<<"Min element is :"<<max<<endl;
   return 0;
}


this is what I got! sorry it took so long trying to learn c++ on the side and got a little busy
Line 5 - your array should be declared to have 10 elements in, not 8.

Lines 12 and 14 - you need semicolons at the end of the lines to end the statements.

Oh, and you got max and min the wrong way round (typo?) in lines 16 and 17.
Last edited on
Topic archived. No new replies allowed.