ExamGecko
Question list
Search
Search

Question 292 - FC0-U61 discussion

Report
Export

Given the following pseudocode:

Which of the following would be the output of the program?

A.
foohappy
Answers
A.
foohappy
B.
barsad
Answers
B.
barsad
C.
foosad
Answers
C.
foosad
D.
barhappy
Answers
D.
barhappy
Suggested answer: C

Explanation:

The pseudocode given in the question is a program that assigns different values to the variable NAME based on the values of the variables TIME and DATE. The program starts by initializing the variables NAME, TIME, and DATE with empty strings, "NOON", and "Monday" respectively. Then, it uses two nested IF-ELSE statements to check the values of TIME and DATE and modify the value of NAME accordingly. The first IF-ELSE statement checks if TIME is equal to "NOON". If it is, it sets NAME to "foo". If it is not, it checks if TIME is equal to "MIDNIGHT". If it is, it sets NAME to "bar". If it is not, it does nothing. The second IF-ELSE statement checks if DATE is equal to "Monday". If it is, it concatenates "sad" to the end of NAME. If it is not, it checks if DATE is equal to "Friday". If it is, it concatenates "happy" to the end of NAME. If it is not, it does nothing. Finally, the program prints the value of NAME. Since the values of TIME and DATE are "NOON" and "Monday" respectively, the program will set NAME to "foo" in the first IF-ELSE statement and then add "sad" to it in the second IF-ELSE statement. Therefore, the output of the program will be "foosad".Reference:CompTIA IT Fundamentals (ITF+) Certification Guide, pages 216-217.Pseudocode - Designing an algorithm - KS3 Computer Science ... - BBC.

asked 02/10/2024
Swen Evers
39 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first