C Language

What is an Array – C Programming

Array is a collection of similar type of data and each data items called elements of array. The data types of the elements may be of any valid data type like char, int, and float etc.

The elements of an array shows the same variable name but element has a different index number known as subscript.

Arrays can be single dimensional or multi-dimensional. The number of subscript determine the dimension of array. A one dimensional array has one subscript while two-dimensional and so on. The one dimensional arrays are known as vectors and two dimensional are known as matrices.

Last cell of the array : n-1

if n = 5

then, 5-1 = 4

Syntax of Array

data_type arrayName [size];

data_type arrayName[size]; /*Single Dimension*/

data_type arrayName[size][size]; /*double dimension*/

Example Program :

void main()
char name[10];
printf("Enter any name : ");
scanf("%s", &name);
printf("My name is : %s", name);

Output :

Output of Above program compiled using Coding C Android App

Similar Posts