Limited access

Upgrade to access all content for this subject

The following are descriptions of several procedures and code segments you will need for this question:

>adds the text as a comment; does not affect the code, only serves as documentation

>returns the character of the String x at index i

x.substring(a, b) 
>returns the substring of x from character a to character (b - 1)

>returns the length of the String x
Note that the index of the first character of a String is 0.

Consider the following procedure with one parameter (x):

PROCEDURE pro (x) {
    n ← x.length
    result ← ""
    REPEAT UNTIL (n = 0) {
        result ← result + x.charAt(n - 1)
        n ← n - 1
    RETURN result

Which of the following comments would be helpful to document the procedure?


//returns the string backwards


//takes a string and returns the string backwards


//uses a while loop to reverse the parameter string


//reverses the string

Select an assignment template