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

please help!! 1There is a singer everyone has heard,Loud, a mid-summer and a mid-wood bird,Who makes the solid tree trunks sound again.He says that leaves are o
what should be done to solve x + 14 = 21
Where in the process of extracting energy from glucose is the nadh oxidized by complex i formed?
What is the point slope form of the line with slope2/5that passes through the point (-4,-7)​
How were native Americans affected by the outcome of the French and Indian war?? And what page is it on??
Emily is 62 years old. Colin is 3 years older than Emily. Dan is 8 years younger than Emily. What is the total of their combined ages?
What is the area of this triangle when x= 4 cm? A. 896cm^2 b.16cm^2 c.240cm^2 d.448cm^2
What are the express powers responsibilities of the president?
help ;--;I will give 95 points.plz, answer.​
what did the suez crisis show about power in the cold war