Thursday 27 February 2020

Array in C Programming Language - tccicomputercoaching.com

What is Array?

Array is collection of more than one element of same type at a same memory location.


Declaration Syntax:

Data Type arrayname[size];

Here, size represent number elements stored in Array. This size is maximum so, user can enter equal or less elements but nor more than elements.

rn[0]
rn[1]
rn[2]
rn[3]
All Elements store in sequence in memory. An each element contain position which always start from zero.


0 1 2 3

For Example , if we want to store 4 student rollno at a same location then array has been declared like this:

int rn[4];

Advantage:

Variable cannot store more than one data at a time. Array removes this limit of variable.

Disadvantage:

Array can store an elements of same type only.

To enter data in given an array:

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

{

Scanf ("%d'',a[i]);

}

To display data in given an array:

For (i=0;i<n;i++)

{

Printf ("%d'',a[i]);

}

We can find maximum element , minimum element , sort the array , search an element from an Array.

To learn coding in C Language at TCCI

Call @ 9825618292

No comments:

Post a Comment