The While loop gets its name from the way it works: While a condition is false, do some…
- User
The While loop gets its name from the way it works: While a condition is false, do some task. True or false?
- Assistant
False. The While loop gets its name from the way it works: While a condition is true, do some task.
- User
Hello, why is the statement false?
- Assistant
The statement is false because the While loop actually continues to execute the task as long as the condition is true, not false. If the condition is false, the loop stops executing the task. So, the correct statement should be: While a condition is true, do some task.
- User
Thank you for explaining that. I am trying to prepare for my CIST 1305 final. Can you share some practice questions for pseudocode? I need to know how to:
-
how to write if-then-else statement in the program.
-
how to write a for-loop in the program.
-
how to write an input validation loop.
-
how to handle parallel arrays.
-
- Assistant
I'm happy to help you prepare for your final! Here are some practice questions and their corresponding pseudocode examples:
- Question: Write a pseudocode if-then-else statement that checks if a number is even or odd.
Pseudocode:
IF num MOD 2 = 0 THEN PRINT "The number is even." ELSE PRINT "The number is odd." ENDIF- Question: Write a pseudocode for-loop that iterates through numbers from 1 to 10 and prints each one.
Pseudocode:
FOR i = 1 TO 10 PRINT i ENDFOR- Question: Write a pseudocode input validation loop that asks the user for a number between 1 and 100, and ensures the input is within that range.
Pseudocode:
REPEAT PRINT "Enter a number between 1 and 100:" INPUT number UNTIL (number >= 1) AND (number <= 100)- Question: Write a pseudocode program that uses parallel arrays to store and display information about three books.