185k views
4 votes
Write an algorithm to sumn of even numbers from 1 to 10​

1 Answer

4 votes

Answer:

1. Start

2. Evensum = 0

3. For I = 1 to 10

3.1 If I % 2 == 0

3.1.1 Evensum = Evensum + I

4. Print Evensum

5. Stop

Step-by-step explanation:

The line by line explanation is as follows:

[The algorithm starts here]

1. Start

[This initializes Evensum to 0]

2. Evensum = 0

[This iterates from 1 to 10, inclusive]

3. For I = 1 to 10

[This checks if current number is even number]

3.1 If I % 2 == 0

[If yes, this adds the even number]

3.1.1 Evensum = Evensum + I

[This prints the sum after the sum]

4. Print Evensum

[This ends the algorithm]

5. Stop

User Victor Zamanian
by
4.8k points