What's wrong with this code involving arrays?

My code is below:

The basis behind it is very simple, we want the program to output 25 decimal numbers between 0 and 1 that are evenly spaced. I have written the code below, but when I run it, it crashes. Can anyone tell me what is wrong? I do not understand arrays in c++ at all.
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
#include <iostream>


using namespace std;

int main()
{
    int n, x;
    int seq[n];
    
    for (n=0; n<=25; n++)
    {
        seq[n]=n/25;
    }
    
    for (n=0; n<=25; n++)
    {
    cout << seq[n] << ", " <<;
}


system("pause");
return(0);

}
Last edited on
Please edit your post and make sure your code is [code]between code tags[/code] so that it has syntax highlighting and line numbers, as well as proper indentation.

If you are only concerned with output, why do you even need an array at all? Just output the numbers directly.
The problem was to edit existing code which had the array in.
Since my question wasn't answered I was able to figure it out for myself, so if anyone else needs the answer to this problem the code is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>


using namespace std;

int main()
{
    int n;
    double seq[25]; 
    
    for (n=0; n<25; n++)
    {
        seq[n]=n/25.0;
        cout << seq[n] << ", ";
    }
    



system("pause");
return(0);

}
Topic archived. No new replies allowed.