Sample


[br]7 [br]The principle behind arrays and the switch statement is the same: we don't want to waste time, writing the same thing over an over. <strong>An array is set of variables of the same type.</strong> These variables <strong>share the same name</strong> - the one given to the array - and can be distinguished only by a <strong>numeric ID called index</strong>. The index is the position of an element in an array, <strong>starting from 0</strong>: <em>the index of the first element will be 0, the second one's will be 1 and so on</em>. An array is created as follows: [crayon-5daf6ddfb2d85233874776/] and can be initialised using curly brackets: [crayon-5daf6ddfb2d91537964092/] To get a variable form an array, use its <strong>index</strong>: [crayon-5daf6ddfb2d95579056673/] You can also create arrays of arrays: these are called <strong>multi-dimensional arrays</strong>. The concept is the same, but instead of a set of variables you have a set of sets of variables. Read this for a detailed explanation: <a href="https://itszephyro.com/blog/learn-c/multidimensional-arrays/" rel="noopener" target="_blank">https://itszephyro.com/blog/learn-c/multidimensional-arrays/</a> <i>Yes, you can create arrays of arrays of arrays of.... you got it</li> [br]https://itszephyro.com/blog/learn-c/c-for-loop/[br]#include <stdio.h> int main() { int array[5] = {2, 3, 5, 7, 11}; //++ is an operator //i++ is equal to i=i+1 for(int i=0; i<5; i++) { printf("The value of the element with index %d is %d", i, array[i]); } } [br]

[br]7
[br]The principle behind arrays and the switch statement is the same: we don’t want to waste time, writing the same thing over an over.

An array is set of variables of the same type.

These variables share the same name – the one given to the array – and can be distinguished only by a numeric ID called index.

The index is the position of an element in an array, starting from 0: the index of the first element will be 0, the second one’s will be 1 and so on.

An array is created as follows:

and can be initialised using curly brackets:

To get a variable form an array, use its index:

You can also create arrays of arrays: these are called multi-dimensional arrays.

The concept is the same, but instead of a set of variables you have a set of sets of variables.

Read this for a detailed explanation: https://itszephyro.com/blog/learn-c/multidimensional-arrays/

Yes, you can create arrays of arrays of arrays of…. you got it

[br]https://itszephyro.com/blog/learn-c/c-for-loop/[br]#include

int main() {
int array[5] = {2, 3, 5, 7, 11};
//++ is an operator
//i++ is equal to i=i+1
for(int i=0; i<5; i++) { printf("The value of the element with index %d is %d", i, array[i]); } } [br]

To learn more, visit: