Showing posts with label array in c. Show all posts
Showing posts with label array in c. Show all posts

2.13.2013

Array in C

Before you kick start to reading array, you should understand why array concept is comes? How it is requires in C?

Let's read following program:

#include<stdio.h>
int main()
{
 int r;
 r=1;
 r=2;
 printf("The value of r = %d",r);
 getch();
 return 0;
}

The output of above program would be:
The value of r = 2

So, you can understand that when the value 2 is assigned into r, the earlier value of r (i.e. 1) is lost. Thus the ordinary variables are capable of holding only one value at a time.
What we do if we would want to store more than one value at a time in a single variable?
Here, the comes the concept of array.