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

if you answer all three ill give you brainllest
Pros and cons of A levels in state school vs private school?
Hello could some one please help me !!
help me with this math question please I'm giving away brainliests​
How many grams of iron oxide, Fe2O3 will be produced if 165 g of O2 gas is supplied? (follow the same steps as mol to mol, only now your flow should be like thi
what are the reasons for expansion of human life to diffrent parts of the world in neolithic age?explained​
write √ 45 + √ 20 in the form k √ 5
Find the volume of the figure below
Gina wants to take dance classes. She compares two dance studios to determine which has the best deal for her. Dance World charges a rate for each class. Toe Ta
If you place a 35-foot ladder against the top of a 26-foot building, how many feet will the bottom of the ladder be from the bottom of the building? Round to th