Quiz6-Functions Flashcards
Library functions are built into a programming language and can be called whenever they are needed.(T/F)
True
The input column in an IPO chart describes the process that the function performs on input data.(T/F)
False
Many programming languages let you assign an integer value to a real variable without causing an error(T/F)
True
Random numbers are useful in simulation programs where the computer must randomly decide how an object will behave(T/F)
True
The function body follows the function header in a function definition.(T/F)
True
The TO INTEGER function accepts a real number as its argument and preserves any fractional part in the returned number.(T/F)
False
When a function finishes executing, it returns a value back to the part of the program that called it.(T/F)
True
If the string variable name has the value “Anne Marie”, then the following statement would return 9: (T/F)
Set number = length(name)
False
If the string variable name has the value “Anne.Smith”, then the following statement would return annesmith. (T/F)
Set newName = toLower(name)
False
If the integer variable number has the value 5, then the following statement would return 25 to result.(T/F)
Set result = sqrt(number)
False: sqrt(5) would not be 25
Given an integer variable number, the only possible values for number that could result from the following statement are 1 and 2.
Set number = random(0,2)
False
The following pseudocode would display: Hello, friend. (T/F)
Declare String str1=”Hello,”
Declare String str2=” friend”
Set message = append(str1,str2)
Display message
True
A function ___________ specifies the return data type, name of the function and the parameter variable(s).
header
Which function accepts two strings as arguments and returns TRUE if the second string is contained in the first string or FALSE if not?
contains
Which function returns a string that is within another string?
substring
Which function joins two strings?
concatenate
What is the value of y after the following statement is coded and executed, given that x = 25?
Set y = sqrt(x)
5
What is the value of y after the following statement is coded and executed, given that x = 3?
Set y = pow(x, x)
27
bc (3^3)= 33=93=27
What is the value of r after the following statement is coded and executed?
Declare Integer i = 12
Declare Real r
Set r = toReal(i)
A) 12
B) 1.2
C) 12.0
C) 12.0
What would display if the following pseudocode is coded and executed?
Declare String str1= “car”
Declare String str2=”green”
Set message = append(str1, str2)
Display “You have a “, message
A) You have a greencar
B) You have a green car
C) You have a cargreen
C) You have a cargreen
append means to squish together
A _________ is a module that returns a value back to the part of the program that called it.
function
A function _________ comprises one or more statements that are executed when the function is called.
Body
What is the data type of the value returned by the random function?
A) Real
B) String
C) Boolean
D) Integer
D) Integer
The __________ function does the same thing as using the mathematical ^ operator.
“pow”