diff --git a/source/_posts/T2.md b/source/_posts/T2.md index 2f8d29f..1f762fe 100644 --- a/source/_posts/T2.md +++ b/source/_posts/T2.md @@ -66,36 +66,36 @@ _References:_

-**COMPETITIVE PROGRAMMING** -**CP AUTHORS: KAUSHIK KUMBHAT and SHYAM PRASATH** +**Competitive Programming** +**Authors - Kaushik Kumbhat and Shaym Prasanth** -**Arrays** - -• An array is a collection of data storage locations, each having the same data type and the same name. -• An array can be visualized as a row in a table, whose each successive block can be thought of as memory bytes containing one element. +**Arrays** + +- An array is a collection of data storage locations, each with the same data type and name. +- +- An array can be visualized as a row in a table, whose each successive block can be thought of as memory bytes containing one element. +- +- Each storage location in an array is called an array element. -• Each storage location in an array is called an array element. - - -**Arrays are of two types:** +**Arrays are of two types:** -• Single or One dimensional arrays. +- Single or One-dimensional arrays. -• Multidimensional eg. two dimensional arrays. +- Multidimensional eg. two-dimensional arrays. + -Single Dimensional Arrays - +**Single Dimensional Array** -• A single dimensional array has only a single subscript. +- A single-dimensional array has only a single subscript. -• A subscript is a number in brackets that follows an array name. +- A subscript is a number in brackets that follows an array name. -• This number can identify the number of individual elements in the array. +- This number can identify the number of individual elements in the array. -• Individual array elements are stored in sequential memory locations. +- Individual array elements are stored in sequential memory locations. ![image](https://github.com/user-attachments/assets/70a2b23d-545f-45f7-b4d8-348a002aa0b5) @@ -107,31 +107,33 @@ Single Dimensional Arrays 3. If the address of the age[0] is 2120d and the size of int be 2 bytes, -then the address of next elements shall be - +Then the address of the next elements shall be +```bash age[1] is 2122d age[2] is 2124d age[3] is 2126d age[4] is 2128d - +``` + Accessing array elements -• An element is accessed by indexing the array name. +- An element is accessed by indexing the array name. -• This is done by placing the index of the element within square brackets after the name of the array. +- This is done by placing the index of the element within square brackets after the name of the array. For example: double salary = balance[9]; -• The above statement will take 10th element from the array and assign the value to salary variable. +- The above statement will take the 10th element from the array and assign the value to the salary variable. ![image](https://github.com/user-attachments/assets/4f357c8e-ec6d-4f09-8820-63e538960fd5) -• When the above code is compiled and executed, it produces the following result: +- When the above code is compiled and executed, it produces the following result: +```bash Element[0] = 100. Element[1] = 101. @@ -151,10 +153,10 @@ Element[7] = 107. Element[8] = 108. Element[9] = 109. - +``` -Example : Calculate Average +Example: Calculate Average // Program to find the average of n numbers using arrays