What are Arrays in C-Programming For Beginners 2023

What is the Arrays Concept in C-Programming language?

Today we discuss new forms of representation of data i.e very useful and very fundamental i.e. called arrays. The word array simply means an arrangement that is an arrangement of data, So we can think of for example An array of soldiers or an array of people standing in line or two rows of people standing, a very regular structure of standing people so this is arrays of people. If a consider one row then its a dimensional array if it is two-row then it is called a two-dimensional array.
example of arrays

Now we can have an array of numbers ex. 1,2,3 that is an example of an arrangement of the nonlinear phase, so this is also an example of Array.
So, in conclusion, we can say that array can be formed by the arrangement of objects.
An array can be of integers, real numbers and etc.
Now let us consider an example of integers numbers

storing the arrays in the memory of the system

It is not possible to have some characters, integers, real numbers in only one array. Hence array allows storing data only of one type i.e of integers, real numbers and of characters only.
We know different types of data types:-

  1. int data type,
  2. float data type,
  3. char data type.
Hence we concluded the definition of Array.

An Array is an arrangement of data of the same type int the memory.

Another thing that is used to be considered in arrays that when a user enters a value then each value of integers or real numbers of character will allocate a specific location address.


addressing the arrays in c in the memory.

As shown in figure each value entered as an input of the size of 5 will got a specific location int the memory of the system.



Basic Concepts 
  • Many applications require multiple data item that has common characteristics                -- In mathematics, we often express such groups of data items in indexed forms
  • Why are arrays essential for some applications?

                            --Take an example

                            --Finding the minimum of the set of numbers.


Using Arrays
  • All the data items constituting the group share the same time.
  • Individual elements are accessed by specifying the index.
Now we will learn about storing arrays in the memory.
When we say,
                          int x[10]
 The compiler will store space equivalent to 10 integers in the memory i.e. 10 consecutive integer places. now the things are how many bytes are required. Then you should be acknowledged that every integer needs 2 bytes to store its value in the memory of the system.
So for 10 integers value, you will require 20 bytes to store your 10 integers numbers as the array i.e. 20 locations are required. These things are done by the compiler to store the values before they used in the program.
In c-language, each index value starts from the value 0.


Declaring Arrays
  • Like variables, the arrays that are used in a program must be declared before they used in the program.
  • General Syntax

             --type array-name[size];
             --type specifies the type of elements that will be contained in the array (int, float, char,etc.).
            --size is an integer constant which indicates the maximum numbers of elements that can be stored inside the array.


Example of taking Arrays in the program:-

  •      int marks[7]
             This statement tells the compiler that 5 integers are about to be allocated in the memory of the system i.e. 10 bytes of space will be allocated in the memory. Number of Marks to be stored in the memory of the system and to be executed in the output of the program.

Post a Comment (0)
Previous Post Next Post