From 092a5a4ca8adb686d966291eee2c2c4d985dc9dc Mon Sep 17 00:00:00 2001 From: ayush163 Date: Fri, 7 Dec 2018 15:17:27 +0530 Subject: [PATCH] Add the topic "Address Calculation" to the article (#24317) --- guide/english/c/arrays-and-strings/index.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/guide/english/c/arrays-and-strings/index.md b/guide/english/c/arrays-and-strings/index.md index 5288559b62..e6f96049c8 100644 --- a/guide/english/c/arrays-and-strings/index.md +++ b/guide/english/c/arrays-and-strings/index.md @@ -63,6 +63,14 @@ int main(void) { return 0; } ``` +## Address Calculation +In C, an array is stored in row major form. Suppose an arrar int A[10] is declared. It will be stored as shown below: +```C + A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9] + ``` + Hence, address for the ith element of the array can be calculated as follows: + + `Address of A[i] = Base Address + i*(size of data type)` Output will be ```C