# An Array? help pls

• 01-04-2007
soundwave
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.
• 01-04-2007
Daved
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?
• 01-04-2007
soundwave
all i have is the info above.. how do u think i shuld go about it?

chers
• 01-04-2007
Daved
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.
• 01-04-2007
soundwave
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
• 01-05-2007
soundwave
help a student:D
• 01-05-2007
Salem
> 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.
• 01-05-2007
soundwave
ah you are right i think more simple than i thought. hmmm
• 01-05-2007
soundwave
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
• 01-05-2007
soundwave
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.
• 01-05-2007
Bench82
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?
• 01-05-2007
Salem
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.