Answer:
Flowchart:
START
Set sum = 0
Set i = 1
WHILE i <= 100
IF i % 2 == 1
Set sum = sum + i
END IF
Set i = i + 1
END WHILE
Display sum
STOP
Pseudo code:
sum = 0
for i = 1 to 100
if i % 2 == 1
sum = sum + i
end if
end for
display sum
Program code in Python:
python
sum = 0
for i in range(1, 101):
if i % 2 == 1:
sum += i
print(sum)
Output: 2500
Step-by-step explanation:
- The program initializes the sum variable to 0 and uses a for loop to iterate through the numbers 1 to 100. The if statement checks if the current number is odd (i % 2 == 1) and if so, adds it to the sum variable. Finally, the program displays the sum of all odd numbers from 1 to 100, which is 2500.