# Thread: Data into an Array

1. ## Data into an Array

I am writing a programme at the moment where i need to
calculate a range of values and put them into an array. however the values are all co-ordinates (X&Y) for a curve and so i am using
a loop to produce the values so i cant just enter them all in one
go, i would have to enter them bit by bit.
IS this right and if so, how do i do it, if not and theres a much simpler way, what is it?!?

Toph

2. Seems like a loop is a reasonable way to go.
Give it a shot and see what happens

3. ok, so how do i go about doing that?
Arrays are something which ive never quite grasped! could you
give me an example or direct me to a tutorial or something?

Thanks

4. An array is a collection of data of a given type. Each element in the array is at a given index. An array element is the individual data segment or piece in the given array. An array index is the position in the array that a given element is at. Think of houses on a street. Each one is at a specific spot on the street. Thus, we could index them, or give them a number so we can remember where they are. Indexes start at 0 and go through the size of the array minus one.

Here is an example:
Code:
```#include <stdio.h>
int main( void )
{
int houses[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int myhouse = 3;

printf("My house is at index 3. So...\n");
printf("houses[3] contains the value %d", houses[myhouse] );

return 0;
}```
What do you think the value you get for houses[3]?
Were you right?

I'll leave working with loops as an exercise to the reader. But there is a brief example of how arrays work.

Quzah.