Arrays (Linear Data Structure)
How to initialize arrays?
Note: If char data types then each element enclosed with single quote.
{'x','y','z'}};
How to display arrays elements?
printf("%c",name[2]);
int age[3]={10,20,30};
printf("%d",age[1]);
{'x','y','z'}};
printf("%c",name[0][2]);
printf("%c",name[1][2]);
- The array is a data structure in C language.
- It can store a fixed-size.
- It can store value in sequential collection of elements.
- It has the same data type for all elements.
- Syntax:
- Example:
- Types of Array:
- An array can be One-Dimensional, Two-Dimensional and Multidimensional.
- One-Dimensional
- Syntax:
- Example:
- Two-Dimensional
- Syntax:
- Example:
- Multidimensional
- Syntax:
- Example:
How to initialize arrays?
- One-Dimensional
- Syntax:
- Example:
Note: If char data types then each element enclosed with single quote.
- Two-Dimensional
- Syntax:
- Example:
{'x','y','z'}};
How to display arrays elements?
- One-Dimensional:
- Syntax:
- Example:
printf("%c",name[2]);
int age[3]={10,20,30};
printf("%d",age[1]);
- Two-Dimensional:
- Syntax:
- Example:
{'x','y','z'}};
printf("%c",name[0][2]);
printf("%c",name[1][2]);