Explain declaration, initialization of One dimensional and Two dimensional arrays.


==> One Dimensional Array---

               Declaration::

                      Syntax: data_type array_name[array_size];

                                   where, data_type can be int, float or char.

                                   array_name is the name of the array.

                                   array_size indicates number of elements in the array.

                                   For ex: int age[5];

             Initialization::

                          Syntax: data_type array_name[array_size]={v1,v2,v3};

                                       where, v1, v2, v3 are the values

                                       For ex: int age[5]={2,4,34,25,18};

==> Two Dimensional Array----

             Declaration::

                            Syntax: data_type array_name[array_size][array_size];

                                          where, first index shows the row number of the element and

                                                         second index shows the coulmn number of the element

            Initialisation::

                             Syntax: data_type array_name[array_size][array_size]={V1,V2,V3,.....Vn};

                                           where, V1, V2, V3,......,Vn are the values

                             For ex: int matrix[2][3]={2,4,56,3,6};



Share to whatsapp

More Questions from Data Structures and Algorithms Module 1

What are pointers? How do we use pointers to different data types?


View

Why do we need dynamic memory allocation techniques? Explain the functions available for allocating memory dynamically.


View

Define array. Explain review of arrays


View

Define data structure. Explain data structure operations ?


View

Explain Structure ?  Define briefly about Memory representation of structure and structure initialization.


View

Define string. Explain string handling functions


View

Define polynomials. Explain Abstract data type in polynomial ?


View