answersLogoWhite

0

Example of an array

Updated: 8/10/2023
User Avatar

Wiki User

12y ago

Best Answer

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

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

how do you use a array?

This answer is:
User Avatar

Add your answer:

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

What are benefits of array in java?

array example in java


What are the parts of an array?

Its type, name and number of elements. char example[12]; // a char array, named 'example' with 12 elements. The name is also a reference to the array itself, referring to the first element in the array (e.g., example == &example[0]).


What is an multiplication array?

A multiplication array is for example 30<10times9<2times5times3times3 and2times3 times3times5 that what is an array


Can you give an example of array using character variable in c program?

the example of array over charcter variables is char ["string"]


What is example of two dimentional array?

a matrix


Can an array contain elements of an object type?

Yes. An array of arrays is nothing more than a multi-dimensional array.


A real life example of an array?

train schedule


Explain the design and application of arrays and how an array simplifies program development?

I need an example of a real-world array


Under what circumstances is a file more useful than an array?

For example: if you want to store data on a disk, it will be a file, not an array.


What is array What is difference between array and simple variable?

An array stores several values - for example, several numbers - using a single variable name. The programmer can access the individual values with a subscript, for example, myArray[0], myArray[5]. The subscript can also be a variable, for example, myArray[i], making it easy to write a loop that processes all the elements of an array, or some of them, one after another.


How do you find address of an element in a 3d array?

C-style example: sometype array [P][Q][R]; addr (array,I,J,K) = (char *)array + sizeof (sometype)*(I*Q*R + J*R + K)


How 2 write c code of array data structure?

An example: int array [10]; yaaa this is write but for a simple programs on array and all data structure visit codingdatastructure.blogspot.com