jonestheprob1150 jonestheprob1150
  • 23-05-2022
  • Computers and Technology
contestada

Write a pseudo code to print sum of all even numbers from 1 to 100

Respuesta :

notleoprobably
notleoprobably notleoprobably
  • 03-06-2022

(python) Answer:

sum = 0

for i in range 1 to 101:

 if i modulo 2 == 0:

   sum += i

print(sum)

Explanation:

first we declare the sum variable

then go through all numbers 1 through 100 (range 1 to 101 because python range does not include the last number - if we did 1 to 100 it would look at 1 to 99)

if the number is even (divide by 2, check if there's a remainder, if not it's even and we will add the number to the sum

finally print the sum

Answer Link

Otras preguntas

how many moles of water H2O contain 2.0 x 10^22 molecules of water? express the quantity in moles to two significant figures
what is 2/3+3k/4=71/12 how do u solve this
Explain the pattern 322 and 32.2 and 3.22 and 0.322
If you're aerobically fit you can?
the first nation in europe to give all men the right to vote was______..
Juan learns that his favorite local public park is going to be turned into a shopping mall. He is quite upset at the thought of losing his favorite park. This i
By the time shana had completed 3/8 of her first lap in a race, she had also completed 1/32 of the entire race. How many laps were there in the race.
how do enzymes work in the stomach?
what is 10 5/16-(5 1/4 +2 9/16)
How did many southerners view the North in the mid-1800s? Southerners thought that the North's wage labor system was a bad system. Southerners thought that the