Add "Difference between array and pointer" (#24541)

pull/24090/head^2
Ishita Bansal 2018-12-20 12:33:05 +05:30 committed by Aditya
parent e929a31bc0
commit 9a10046c2f
1 changed files with 4 additions and 0 deletions

View File

@ -51,6 +51,10 @@ numbers[2] = 55; // Sets the third position (index 2) to the new value 55
//numbers[] is now: {1, 2, 55, 4, 5}
```
### What is the difference between arrays and pointers?
An array is a collection of variables of similar data type that are stored in contiguous memory locations whereas the pointer is a variable that stores the memory address of another variable i.e. a pointer is a variable that points to the location of another variable.
How to insert and print array elements:
```C++
int vnum[5] = {1, 2, 3, 4, 5}