Tuesday, November 8, 2022

array in c | Sytax | Type of array | Question

 Array

Array is a collection of same data type .

C program provides two type array

1. Fixed Length Array

2. Variable Length Array

In which each and every element stored in continous memory 


location.

It is derived data type 


Sytax Array in c 

DataType variableName [ size of array ]

exam- int a[6]

int= datatype , a = array variable , [6] = size of 


array


Index--

The index position of the first element of array is start  with 0 .

The index position of the last element of array ends with N-1 


Type of Array 

C support following two type of array 

   1. One demensional array

   2. Multi demensional array


One Dimensional Array

one demensional array is the part of array which contain only  a single subscript.

   Or 

one demensional array can be think as the single row of  table.

exam- a[0], a[1], a[2], a[3], a[4]


Multi Dimensional Array

Array with more then one demensional are called multi demensional array. Many application require that data be stored in more the one demensional.

When we need to store data from of matrices or table.


Mcq on array in c


1.An array is a collection of .

    1) different data type

    2) same data type

    3) both 1 & 2

    4) None


2. Array element are stored in 

    1) scattered memory location

    2) sequential memory location

    3) both 1 & 2

    4) None of these


3. A character array always ends with_.

    1) null ("\0")

    2) Question mark (?)

    3) full stop (.)

    4) none of these


4. All the element in the element in the elements in the array must be.

    1) initialized

    2) defined

    3) both 1 & 2

    4) None


5. What index value should be used to access the last element of integer array N[10].

    1) 10

    2) 9

    3) 11 

    4) None


6. The process of creating a fixed sized array by allocating memory space at compile time called___.

    1) static memory allocation

    2) run time memory allocation

    3) dynamic memory allocation

    4) None of the above


7. The variable used as a subscript in an array is popularly know as______ variable .

    1) Control

    2) Index

    3) Constant

    4) None of the above



No comments: