Get the technologies, internet, technology news and more. You can know about technologies and you are at right place for knowing knowledge.

Tuesday, October 23, 2018

C programming | Arrays in C programming

C programming | Arrays in C programming: Here you can learn about C programming arrays and pointers. And How it is used in C programming.

Arrays in C programming: Arrays defined as a collection of elements with similar datatype or It is a group of data elements with same datatype. In one variable we can store only one element or data.If you want to store 100 user marks, you want to declare 100 variables. To handle this problem array is used.

In memory array elements are start with 0th position. When we declare array in the program It creates space in the computer memory. And we can access them using its position. Diagram shown below.

Array are stored in computer memory

If you want C programming Introduction I have also created that article you can see in popular or in my website.

There are two types of arrays:
1. One-dimensional Array.
2. Multidimensional Array.

1. One-dimensional Array: One dimensional array is a collection of array elements that can be accessed individually by its single index or postion value. You want to declare the array before using it in the program. Declaration shown below.

Datatype Arrayname[array size];
Ex: Char name[20];

Where char is chararcter datatype and name is arrayname and in bracket size of array for name.

2. Multidimensional Array: C programming allows user to create multidimensional array, i.e name suggests multi dimensional more array in one array name. It indicates as a[i][j] where first array i is row and second array j is column. Declaration of multidimensional array is:

Datatype Arrayname[row_array_size][column_array_size];
Ex: int marks[5][6];

Here marks are two dimension arrary name, this array has 5 rows and 6 columns.

I hope you have understand this article 'C programming | Arrays in C programming' if you have any questions or if you want more information about arrays you can ask me in the comment box I will answer you.

No comments:

Post a Comment