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 me please will give its about negative numbers ​
Skills USA offers the opportunity to practice information technology skills. A. True B. False
What is the distance between A and B?
What are the jobs of the testes?
Read this quotation by Thomas Jefferson from a debate about the national bank. To take a single step beyond the boundaries thus specially drawn around the power
What does Jennifer tell the police? What motive does Jennifer give?
Help please!!! look at attached
each main idea in finding gold, finding Florida HELP ME
how do you separate amixture by using fractional distillation​
Describe the divisions (different beliefs) in american society as reflected in the scopes monkey trial