forked from Kvaibhav01/HackerEarth-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Kvaibhav01#6 from Yashika25/master
ADD ARRAY ELEMENTS
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# ARRAY SUM OF SIZE N | ||
|
||
## This is a solution to HackerEarth problem. Following steps are followed: | ||
|
||
- First, we take the size of the array as input (N). | ||
|
||
- Then, the array is declared to be of integer type. | ||
|
||
- The space separated array elements are taken as input from user. | ||
|
||
- An integer type variable called *sum* is declared and initialised with value 0 as no array element is added yet. | ||
|
||
- Now, a for loop is used to read each element starting from index 0 to N-1 and are simultaneously added to previous value of sum and array element present at that particular loop index. | ||
|
||
- Lastly, the variable sum which contains the final answer is printed as the output. | ||
|
||
### Find the link to the problem statement here: https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/array-sum-2-725368ac/ | ||
|
||
## #HAPPYCODING ;) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SUM OF SQUARES OF ARRAY OF SIZE N | ||
|
||
## Following steps are followed: | ||
|
||
- First, we take the size of the array as input (N). | ||
|
||
- Then, the array is declared to be of integer type. | ||
|
||
- The space separated array elements are taken as input from user. | ||
|
||
- An integer type variable called *sum* is declared and initialised with value 0 as no array element is added yet. | ||
|
||
- Now, a for loop is used to read each element starting from index 0 to N-1 and are simultaneously added to previous value of sum and array element present at that particular loop index is added two times. | ||
|
||
- Lastly, the variable sum which contains the final answer is printed as the output. | ||
|
||
## #HAPPYCODING ;) |