correct greeting procedure answer and explanation
Correct Greeting Procedure Assignment Answers
Question:
A program's expected function is to return a greeting message, including the user's name. Review the AP Exam pseudocode code segment below. x ← INPUT() y ← greeting(x) DISPLAY(y) Which of the following is the correct implementation of the greeting() procedure? PROCEDURE greeting(name) { DISPLAY(Concat("Good Morning ", name)) } PROCEDURE greeting(x) { DISPLAY(Concat("Good Morning ", name)) } PROCEDURE greeting(name) { RETURN(Concat("Good Morning ", name)) } PROCEDURE greeting(name) { RETURN(Concat("Good Morning ", "name")) }
Correct Greeting Procedure Answer and Explanation
- This option has an issue. It uses the variable `name` without declaring it as a parameter or assigning it a value. It should be `x` instead.
3. PROCEDURE greeting(name) { RETURN(Concat("Good Morning ", name)) }
PROCEDURE greeting(name) {
DISPLAY(Concat("Good Morning ", name))


