0% found this document useful (0 votes)
3 views

Computer Science Pseudocode

Uploaded by

k225168
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Computer Science Pseudocode

Uploaded by

k225168
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Computer Science Pseudocode

1. Product of Numbers Until a Negative Number is Entered


Question: Write pseudocode to multiply numbers input by the user until a negative
number is entered. Then, print the product of the numbers entered.
Hint: Use a WHILE loop to keep multiplying the numbers until the condition (number
< 0) is met.
2. Count of Even Numbers Until a Zero is Entered
Question: Write pseudocode to count how many even numbers the user enters until a
zero is input. Print the count of even numbers.
Hint: Use a WHILE loop and check if the number is even using number MOD 2 = 0.
3. Sum of Odd Numbers Until an Odd Number Greater Than 50 is Entered
Question: Write pseudocode to calculate the sum of odd numbers input by the user
until an odd number greater than 50 is entered.
Hint: Use a loop that continues until the condition number > 50 AND number MOD 2 ≠
0 is met.
4. Find the Smallest Number Until a Prime Number is Entered
Question: Write pseudocode to continuously accept numbers from the user until a
prime number is entered. Find and print the smallest number among those entered
before the prime number.
Hint: Use a WHILE loop to keep track of the smallest number and exit the loop when
a prime number is found (you may need a function to check if a number is prime).
5. Sum and Count of Positive Numbers Until a Negative Number is Entered
Question: Write pseudocode to find the sum and count of all positive numbers
entered by the user until a negative number is entered.
Hint: Use a WHILE loop to add positive numbers to the sum and increment a counter,
stopping when a negative number is entered.
6. Calculate Average of Numbers Until the User Enters a Specific Value (e.g., 999)
Question: Write pseudocode to calculate the average of numbers input by the user
until they enter a specific value like 999, which signals the end.
Hint: Use a loop that stops when the input equals the specified value and then
calculates the average.
7. Find the Largest Even Number Until an Odd Number is Entered
Question: Write pseudocode to find the largest even number entered by the user
until an odd number is input.
Hint: Use a WHILE loop to keep track of the largest even number, and stop when an
odd number is entered.
8. Count How Many Numbers Are Divisible by 3 Until a Non-Divisible Number is
Entered
Question: Write pseudocode to count how many numbers entered by the user are
divisible by 3 until a number that is not divisible by 3 is entered.
Hint: Use a loop and the modulus operator MOD 3 = 0 to count and stop the loop when
a non-divisible number is found.
9. Accumulate Sum Until the Sum Reaches or Exceeds a Certain Value
Question: Write pseudocode to keep adding numbers entered by the user until the
accumulated sum reaches or exceeds a certain value (e.g., 100).
Hint: Use a WHILE loop that continues adding numbers until the sum is greater than
or equal to the specified limit.
10. Calculate the Average of Numbers Until a Negative Number or a Number Greater
Than 100 is Entered
Question: Write pseudocode to calculate the average of numbers input by the user
until they enter a negative number or a number greater than 100.
Hint: Use a loop that stops when the input meets the specified condition and
calculates the average of the valid numbers entered.

You might also like