# Thread: An Array? help pls

1. ## An Array? help pls

now then, ive been researching arrays for a while, but can't seem to find how to do this still..

I need to write a program to generate the co-ordinates of twenty-five elements for a square.

this square shape is 1m by 1m.

I need it to read the program inputs:

no. of element
the length of the shape
width of shape
store the output in another file.

2. What data will you be storing? How will you use an array to store that data. Will you need more than one array?

Once you know what array(s) you need, you have to declare it. To declare it, you need to know its size. Can you figure out how large to make the array based on the assignment above?

3. all i have is the info above.. how do u think i shuld go about it?

chers

4. I think you should think about the questions I asked. That's how you should start. Figure out the answers to those questions and you will be on your way.

5. Code:
```#include <iostream>
using namespace std;

int main()
{
int x,y;
int array[5][5];

for ( x = 0; x < 5; x++ )
for ( y = 0; y < 5; y++ )
array[x][y] = x * y;
}```
now, this is the matrix, but im not too sure what can i do next

6. ## help a student:D

Any ideas ppl please?

7. > I need to write a program to generate the co-ordinates of twenty-five elements for a square.
> this square shape is 1m by 1m.
You mean like there is a square at 0cm,0cm to 20cm,20cm
And a square at 0cm,20cm to 20cm,20cm

all the way up to
a square at 80cm,80cm to 100cm,100cm

You don't need a 2D array for that, just a couple of for loops and some cout statements.

8. ah you are right i think more simple than i thought. hmmm

9. ok, so far I've got this, i think im on the right lines

can anyone help complete?

Code:
```using namespace std;

int main()
{
int length;
int width;
int x,y;   // row, column

cout << "Input the size of the length of the square"; // asks user for size of the side
cin >> length;

cout<<"input the size of width of the square";
cin>>width

for ( x = 0; i < side; ++x)
{
cout << "*";
}```

chers

10. I need to write a program to generate the co-ordinates of twenty-five elements for a square.

this square shape is 1m by 1m.

I need it to read the program inputs:

no. of element
the length of the shape
width of shape
store the output in another file.

11. Your description of the problem makes no sense at all. If you already know the length & width are both 1m, and the number of elements is 25, what's the point of having the program get input for those values?

12. I dunno, maybe he wants to print something like this
Code:
```*****
*****
*****
*****
*****```
If that isn't what you want soundwave, then actually write out by hand an example of what you expect to type in and an example of what you want to be printed.

"store the output in another file" just doesn't help.

Popular pages Recent additions