for loops

how can i make this function sum between specific arrays using a for loop?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  #include <iostream> //Basic input and output functionality for cout and cin
#include <iomanip> //controls output, lets me print a 'fixed' and 'setprecision' value for question #2
#include <math.h>  // pow

using namespace std; //I call this functionality so I don't have to declare "std" for each function

int main()  //my main function declaration and following is the function within the {
{


    int myArray[5]={}; //set the value of integer 'myArray' to five figures.
    cout<<"Enter 1st number "<<endl; //user input
    cin>>myArray[0]; //user input defined to first value in myArray which is myArray
    cout<<"Enter the 2nd number "<<endl; //user input
    cin>>myArray[1]; //user input defined as the second value in myArray which is '1'
    cout<<"Enter the 3rd number "<<endl; //user input
    cin>>myArray[2]; //defined as the 3rd value in myArray
    cout<<"Enter the 4th number "<<endl; //user input
    cin>>myArray[3]; //user input defined as the 4th value in myArray
    cout<<"Enter the 5th number "<<endl; //user input
    cin>>myArray[4]; //user input defined as the 5th value as myArray



    cout<<myArray[0]+myArray[1]<<endl; 
    cout<<myArray[1]+myArray[2]<<endl;
    cout<<myArray[2]+myArray[3]<<endl;
    cout<<myArray[3]+myArray[4]<<endl;

    if(myArray[0] >=myArray[1] and myArray[1] >= myArray[2] and myArray[2] >=     myArray[3] and myArray[3] >= myArray[4])
        cout<<"True"<<endl; 
    else
        cout<<"False"<<endl; 

    return 0;
}
Your current code is going to give you a TON of errors because of your if statement on line 30. Comment that out and your code should work fine. It will then be much easier to implement the for loop.
Topic archived. No new replies allowed.