Updated index.md (#24997)

* Updated index.md

Added base type and fixed minor errors.

* Grammar fixes
This commit is contained in:
JOS PAUL SHAJAN
2018-12-15 12:11:21 +05:30
committed by Manish Giri
parent ffce49d024
commit b6ac02fdc6

View File

@ -19,11 +19,12 @@ int main(void) {
return 0;
}
```
So, this looks a bit tedious.<br>Up until now every variable created had some special role. But right now, it would be great if we could just store multiple values in one place and get access to the values with their place in the line maybe (first value, second etc.). Another way to look at this is, suppose you want to store a set of names, you need not create different variables for each name, instead you can create an array of names where each name has its unique identity or *index*. Also, we could use loops on them, which are things you will learn about later, but basically they do the same thing over and over again.
So, this looks a bit tedious. Up until now every variable created had some special role. But right now, it would be great if we could just store multiple values in one place and get access to the values with their place in the line maybe (first value, second etc.). Another way to look at this is, suppose you want to store a set of names, you need not create different variables for each name, instead you can create an array of names where each name has its unique identity or *index*. Also, we could use loops on them, which are things you will learn about later, but basically they do the same thing over and over again.
eg. reading from the user, or printing out values.
## Arrays in C
Arrays are containers with a given size. They contain variables of the **same type**. You can access a variable stored in the array with its *index*.
Arrays are containers with a given size. They contain variables of the **same type**. This is called base type of the array. You can access a variable stored in the array with its *index*.
Let's look at some code:
```C
#include <stdio.h>