TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Thursday, 14 May 2020

Different Type Of Array In C Language | Array Type In C Language | Array Type In C Language In Hindi | How Many Type Of Array In C Language

Array Types In C


There are three type of array in c language and they are:

1.One dimensional array

2.two dimensional array

3.multi-dimensional array


image array type in c

Fig: Array type in c

1.   One dimensional array

 

One dimensional array is type of array it use  subscript and the size of array is declare in subscript of array.

 

Syntax:

 

datatype    arrayname[size];

 

Example:

 

int a[5];

 

Program

 

#include<stdio.h>

#include<conio.h>

void main()

{

int arr[5]={10,20,30,40,50};

for(int i=0;i<=5;i=+)

{

printf(“value of arr[%d] is %d \n”,i , arr[i]);

}

getch();

}

 

Output:

 

value of arr[0] is 10;

value of arr[1] is 20;

value of arr[2] is 30;

value of arr[3] is 40;

value of arr[4] is 50;

 

2.    Two dimensional array

 

Its use two subscript first row and second column and array use for creating matrix in which data is store  on memory in table format.

 

Syntax:

 

datatype   arrayname[row][column];

 

Example:

 

int  arr[2][2];

 

 

Program

 

#include<stdio.h>

#include<conio.h>

void main()

{

int  arr[3][3], i,j;

printf(“count 3* 3 Matrix”);

for(i=0;i<=2;i++)

for(j=0;j<=2;j++)

scanf(“%d%d”,&arr[i][j]);

for(i=0;i<=2;i++)

for(j=0;j<=2;j++)

printf(“%d%d”,arr[i][j]);

printf(“\n”);

getch();

}

 

Output:
 

Count 3*3 matrix

2

2

2

2

2

2

2

2

2

222222222

 

1.    Multi-dimensional array

 

In this array we use two are more than two subscript of array.

 

Syntax:

 

datatype   arrayname[size][size][size];

 

Example:

 

int arr[2][2][2];

No comments:

Post a Comment