Chap - 5 C Arrays
Chap - 5 C Arrays
Languages
Chapter 5 : C Arrays
Semester 3
24 octobre 2024
Course outline
4 Arrays dimensions
5 Applications
subtle traps...
Dave Small
1.1. Introduction
An array in C is a fixed-size collection of similar data
items stored in contiguous memory locations.
3 int main () {
4 // array initialization using initialier list
5 int arr [5] = { 10 , 20 , 30 , 40 , 50 };
6
7 /*
8 array initialization using initializer list without
9 specifying size
10 */
11 int arr1 [ ] = { 1 , 2 , 3 , 4 , 5 };
12
13 return 0;
14 }
2.1. Definition
We can access any element of an array in C using the array
subscript operator [ ] and the index value i of the element.
array_name [index];
2.2. Explanation
3.1. Definition
Traversal is the process in which we visit every element of
the data structure.
4.1. Generalities
There are two types of arrays based on the number of
dimensions it has.
6 // printing string
7 int i = 0;
8 while ( arr [ i ]) {
9 printf ( " % c " , arr [ i ++]) ;
10 }
11 return 0;
12 }