Programming Foundations Questions and
100% Correct Answers– WGU
What is the return value of a function?
A Output of a function
B Call to run the function
C Data passed to the function
D Variable in the declaration of the function - correct answer Output of a function
A program should continue accepting input numbers, adding each to a sum, until a 0 is
input.
Which control structure should be used?
A If statement
B For loop
C Multiple if statements
D While loop - correct answer While loop
Joe is building an online game. He wants to provide a riddle and have the player guess
the answer. The game needs to prompt the user to enter the answer, check to see if it
the input provided does not match the correct answer, and continue prompting the
user until the answer entered matches the correct answer.
Which control structure supports Joe's needs?
A For loop
B While loop
C Do-while loop
, D278 Pre-Assessment Scripting and
Programming Foundations Questions and
100% Correct Answers– WGU
D If-else branch - correct answer Do-while loop
What is put to output by the following pseudocode?
x=3
do
Put x to output
Put " " to output
x=x-1
while x > 0
A3210
B 3 2 1 0 -1
C210
D 3 2 1 - correct answer 321
A programmer has developed the following code:
count = 0
while count is less than 5:
print 'Hello'
What is the result of implementing this code?
A 'Hello' will print four times.
B 'Hello' will print five times.
C The program will throw an error.
, D278 Pre-Assessment Scripting and
Programming Foundations Questions and
100% Correct Answers– WGU
D 'Hello' will print indefinitely. - correct answer 'Hello' will print indefinitely
What is the loop expression in the following pseudocode?
i=0
while i < 20
Put i to output
i=i+1
Ai
B i<20 />
Ci=0
D i = i + 1 - correct answer i<20/>
What is the loop variable initialization in the following pseudocode?
y=0
s = 100.0
while y < 10
s = s + (s * 5.0)
y=y+1
Ay=0
By=y+1
C s = 100.0