Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. Instead of declaring individual variables, such as number0, number1, ..., and number99, you declare one array variable such as numbers and use numbers[0], numbers[1], and ..., numbers[99] to represent individual variables. A specific element in an array is accessed by an index. All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element. How to make picture puzzle using JavaScript Declaring Arrays To declare an array in C, a programmer specifies the type of the elements and the number of elements required by an array as follows − type arrayName [ arraySize ]; This is called a single-dimensional array. The arraySize must be an integer constant
Loops in C programming with example A loop is used for executing a block of statements repeatedly until a given condition returns false. Example of For loop #include <stdio.h> int main () { int i ; for ( i = 1 ; i <= 3 ; i ++) { printf ( "%d\n" , i ); } return 0 ; } Output: 1 2 3 Nested For Loop in C Nesting of loop is also possible. Lets take an example to understand this: #include <stdio.h> int main () { for ( int i = 0 ; i < 2 ; i ++) { for ( int j = 0 ; j < 4 ; j ++) { printf ( "%d, %d\n" , i , j ); } } return 0 ; } Output: 0 , 0 0 , 1 0 , 2 0 , 3 1 , 0 1 , 1 1 , 2 1 , 3 Example of while loop #include <stdio.h> int main () { int count = 1 ; while ( count <= 4 ) { printf ( "%d " , count ); count ++; } return 0 ; } Output: 1 2 3 4 Example of while loop using logical operator In this example