answersLogoWhite

0

Here is a statical array:

int arr[50]; /* 50 integers in the array */

/* setting some values */

arr[0] = 1;

arr[1] = 2;

...

int matrix[10][10]; /* we have a matrix 10 x 10 of integers */

/* setting some values */

matrix[0][0] = 1;

matrix[1][1] = 2;

matrix[3][5] = 3;

...

You can initialize array at the time of creation:

int arr[3] = { 0, 1, 3 };

/* or could do like this */

int arr[] = { 0, 1, 2, 3, 4, 5 };

int matrix[2][4] = { 0, 0, 0, 01, 1, 1, 1};

/* is the same as: */

int matrix[2][4] = { { 0, 0, 0, 0 }, { 1, 1, 1, 1} };

C Arrays are no limited only to one and two dimensional arrays, you can define N-dimensional arrays too.

int cube[3][3][3]; /* here we have a cube 3 x 3 x 3*/

There are dynamic arrays too, but that requires knowledge of memory management and pointers. There are some links that will explain arrays in C more detailed.

User Avatar

Wiki User

13y ago

Still curious? Ask our experts.

Chat with our AI personalities

MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
More answers

how do you use a array?

User Avatar

Wiki User

15y ago
User Avatar

Add your answer:

Earn +20 pts
Q: Example of an array
Write your answer...
Submit
Still have questions?
magnify glass
imp