Types of array in C

There are 2 types of C arrays

  • One dimensional array.
  •  Multi dimensional array.( Two dimensional array. Three dimensional array. four dimensional array etc...)






1.Single Dimensional Array :

  1. Single or One Dimensional array is used to represent and store data in a linear form.
  2. Array having only one subscript variable is called One-Dimensional array
  3. It is also called as Single Dimensional Array or Linear Array

Syntax :

<data-type> <array_name> [size];

Example of Single Dimensional Array :

int iarr[3]   = {2, 3, 4};

char carr[20] = "c4learn" ;

float farr[3] = {12.5,13.5,14.5} ;

2. Multi Dimensional Array :

  1. Array having more than one subscript variable is called Multi-Dimensional array.
  2. Multi Dimensional Array is also called as Matrix.

Syntax :

<data-type> <array_name> [row_subscript][column-subscript];

Example : Two Dimensional Array

int a[3][3] = { 1,2,3
                5,6,7
                8,9,0 };



No comments:

Post a Comment

Featured Post

Core and Advance Python

                      Language Fundamentals