C Exercises

Jul 2, 2020

Array in C Definition, Syntax, Working, Advantages & Disadvantages

Definition: Array is collection of similar data types. That means using array we can store similar type of elements.

In short array is  a variable which can store multiple values. For example, if you want to store 100 and more intigers, then you need to create an array for it.


Above syntax shows the  declaration of one dimensional array, for multi-dimensional array just declare-

datatype variablename[size][size]....;

  Advantages of array:

  1. Arrays are used to store collection of data.
  2. Array is used when there is need to use many variable's of  the same datatype.
  3. Memory allocated dynamically in the array which will help to save memory.
  4. It use less amount of code.
  5. We can access any element easily using array name and index.

  Disadvantages of array:

  1. Array is static structure which means array is of fixed size.
  2. Using array we can store only similar type of elements.

  Java program to print given elements:

This program shows you working of array. In this program we will print given elements, on output screen using for loop. This program shows value stored in array with their position.


void main()
int arr[5]={10,20,30,40,50},i;

printf("Elements in array are:\n");



Above program shows the following output:

Array definition, syntax, working, advantages and disadvantages

No comments:

Post a Comment

If you have any doubts, please discuss here...👇