One dimensional array.


A single dimensional array (also called one dimensional array) is a linear list consisting of related data items of same type . In memory all the data items are stored in contiguous memory locations one after the other.

Basic properties of arrays are:-

for-loop-shineskill

Initialization of single dimensional array.


1) Initializing all specified memory Location.
Array can be initialized at the time of declaration when their initial value are known in advance array elements can be initialized with data items of type integer , character , float etc .the value are copied into array in the order specified in the declaration.
        Example:- int arr[5]={ 5, 7, 8, 4, 3 };
2) Initialization without size
       Example:- int arr[ ]={4, 6, 2, 3 , 7};
3) Initialization with a string
       Example:- char arr[ ]=“computer”;
4) Assigning values to array.
      Example:-      int a[5];
                             a[3]=30;

W.A.P to enter 5 numbers and print the value.

#include<stdio.h>
#include<conio.h>
void main()
  {
   int arr[5], i;
   printf(“Enter element of array\n”);
   for(i=0;i<=4;i++)
  {
   scanf(“%d”,&arr[i]);
  }
   for(i=0;i<=4;i++)
  {
   printf(“%d”,arr[i]);
  }
   getch();
  }

Output

Enter element of array.
6 7 3 4 10