Skip to content

Commit

Permalink
Update T2.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Nehal-Khan-29 authored Aug 27, 2024
1 parent 9cfbb06 commit cecb970
Showing 1 changed file with 20 additions and 27 deletions.
47 changes: 20 additions & 27 deletions source/_posts/T2.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ _<span style="color: #ADD8E6">References:</span>_
**<span style="color: #ADD8E6; font-size: 1rem;">Arrays</span>**

- 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.


Expand All @@ -100,11 +100,11 @@ _<span style="color: #ADD8E6">References:</span>_
![image](https://github.com/user-attachments/assets/70a2b23d-545f-45f7-b4d8-348a002aa0b5)


1. In this example “age” is the array of type “int” having 5 elements.
- In this example “age” is the array of type “int” having 5 elements.

2. Each element of the array is identified by the subscript number starting from 0 to 4.
- Each element of the array is identified by the subscript number starting from 0 to 4.

3. If the address of the age[0] is 2120d and the size of int be 2 bytes,
- If the address of the age[0] is 2120d and the size of int be 2 bytes,


Then the address of the next elements shall be
Expand All @@ -121,15 +121,13 @@ Accessing array elements

- This is done by placing the index of the element within square brackets after the name of the array.

For example:
**For example:**

double salary = balance[9];

- 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)

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:

Expand All @@ -156,11 +154,11 @@ Element[9] = 109.
```


Example: Calculate Average
**Example: Calculate Average**

```bash
// Program to find the average of n numbers using arrays


#include <stdio.h> int main() {

int marks[10], i, n, sum = 0, average;
Expand Down Expand Up @@ -191,10 +189,11 @@ printf("Average = %d", average);
return

}
```


Output
**Output**

```bash
Enter n: 5

Enter number1: 45
Expand All @@ -208,18 +207,18 @@ Enter number4: 31
Enter number5: 49

Average = 39

```



Find the Largest/Smallest of the Elements of an Array


We set largest to the value of the first element of the array.
- We set the largest to the value of the first element of the array.

Then we compare this value to each of the other elements in the array.
- Then we compare this value to each of the other elements in the array.

If one is larger, we replace the value in largest with the value and continue to check the rest of the array.
- If one is larger, we replace the value in largest with the value and continue to check the rest of the array.


Flow chart to find the largest of the array
Expand All @@ -228,21 +227,15 @@ Flow chart to find the largest of the array



**TASK:**
_<span style="color: #ADD8E6">Task:</span>_

CREATE AN ACCOUNT IN HACKERRANK PLATFORM AND JOIN IN THE HACKERRANK CHALLENGE VIA THE LINK GIVEN BELOW:

LINK: www.hackerrank.com/task-1-for-2nd-year

**SCORING CRITERIA:**

Each challenge has a pre-determined score.

A participant’s score depends on the number of test cases a participant’s code submission successfully passes.

If a participant submits more than one solution per challenge, then the participant’s score will reflect the highest score achieved. In a game challenge, the participant's score will reflect the last code submission.
_<span style="color: #ADD8E6">Scoring Criteria:</span>_

Participants are ranked by score. If two or more participants achieve the same score, then the tie is broken by the total time taken to submit the last solution resulting in a higher score.
Each challenge has a pre-determined score. A participant’s score depends on how many test cases a participant’s code submission successfully passes. If a participant submits more than one solution per challenge, then the participant’s score will reflect the highest score achieved. In a game challenge, the participant's score will reflect the last code submission. Participants are ranked by score. If two or more participants achieve the same score, then the tie is broken by the total time taken to submit the last solution resulting in a higher score.

<hr>
<hr>
Expand Down

0 comments on commit cecb970

Please sign in to comment.