COMP EXAM 4 QUESTIONS AND ANSWERS
loop/ loop body - CORRECT ANSWER✅✅a program construct that repeatedly executes the loop's
statements (known as the loop body) while the loop's expression is true; when false, execution proceeds
past the loop.
iteration - CORRECT ANSWER✅✅Each time through a loop's statements
while loop - CORRECT ANSWER✅✅a program construct that repeatedly executes a list of sub-
statements (known as the loop body) while the loop's expression evaluates to true
infinite loop - CORRECT ANSWER✅✅a loop that never stops iterating
sentinel value - CORRECT ANSWER✅✅a special value indicating the end of a list, such as a list of
positive integers ending with 0 (ex: 10, 1, 6, 3, 0)
index - CORRECT ANSWER✅✅each string character has a position number called an index, starting with
0 (ex: the S in String is at index 0 and the t is at 1)
at() - CORRECT ANSWER✅✅the notation someString.at(x) accesses the character at the index x of a
string
size() - CORRECT ANSWER✅✅the function someString.size() returns a string's length (ex: if s1 is "Hey",
s1.size() returns 3)
append - CORRECT ANSWER✅✅the function s1.append(s2) adds string 2 to the end of string 1 (ex: if s1
is "Hey" and s2 is "!!!", it makes s1 "Hey!!!")
exception - CORRECT ANSWER✅✅a detected runtime error that commonly prints an error message and
terminates the program
loop/ loop body - CORRECT ANSWER✅✅a program construct that repeatedly executes the loop's
statements (known as the loop body) while the loop's expression is true; when false, execution proceeds
past the loop.
iteration - CORRECT ANSWER✅✅Each time through a loop's statements
while loop - CORRECT ANSWER✅✅a program construct that repeatedly executes a list of sub-
statements (known as the loop body) while the loop's expression evaluates to true
infinite loop - CORRECT ANSWER✅✅a loop that never stops iterating
sentinel value - CORRECT ANSWER✅✅a special value indicating the end of a list, such as a list of
positive integers ending with 0 (ex: 10, 1, 6, 3, 0)
index - CORRECT ANSWER✅✅each string character has a position number called an index, starting with
0 (ex: the S in String is at index 0 and the t is at 1)
at() - CORRECT ANSWER✅✅the notation someString.at(x) accesses the character at the index x of a
string
size() - CORRECT ANSWER✅✅the function someString.size() returns a string's length (ex: if s1 is "Hey",
s1.size() returns 3)
append - CORRECT ANSWER✅✅the function s1.append(s2) adds string 2 to the end of string 1 (ex: if s1
is "Hey" and s2 is "!!!", it makes s1 "Hey!!!")
exception - CORRECT ANSWER✅✅a detected runtime error that commonly prints an error message and
terminates the program