/* */ Click to Join Live Class with Shankar sir Call 9798158723

Single dimensional array in C ?


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.


Initialization of single dimensional array.

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 };
Initialization without size
int arr[ ]={4, 6, 2, 3 , 7};
Initialization with a string
char arr[ ]=“computer”;
Assigning values to array
Int a[5];
a[3]=30;


Q.) W.A.P to enter 5 numbers and print reading/writing 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();
 }