24.1k views
5 votes
Write pseudo code that will count all the even numbers up to a user defined stopping point?

User K M
by
8.4k points

1 Answer

5 votes

Final answer:

To count all the even numbers up to a user-defined stopping point, you can use a loop in your pseudo code. Here's an example in Python.

Step-by-step explanation:

To count all the even numbers up to a user-defined stopping point, you can use a loop in your pseudo code. Here's an example in Python:

stopping_point = int(input('Enter the stopping point: '))
count = 0

for i in range(2, stopping_point+1, 2):
count += 1

print('The count of even numbers is:', count)

In this code, we initialize a variable 'count' to 0. Then, we use a 'for' loop that starts at 2 (the first even number) and goes up to the stopping point (inclusive), incrementing by 2 in each iteration. Inside the loop, we increase the 'count' by 1 for each even number encountered. Finally, we print the value of 'count'.

User Sam Ho
by
7.5k points