Chapter 6 (Pretest)

Ace your homework & exams now with Quizwiz!

6.7 Look at the following pseudocode function definition: Function Integer doSomething(Integer number) Return number * 2 End Function 1. What is the name of the function? 2. What type of data does the function return? 3. Given the function definition, what will the following statement display? Display doSomething (10)

1. doSomething 2. Integer 3. 10

6.2 What is a library function?

A prewritten function that comes with a programming language.

7. This type of function returns either True or False.

Boolean

3. In many languages it is an error to assign a real number to an integer variable.

False (Most languages let you assign an integer value to a real variable without causing an error because doing so does not cause a loss of data.)

6. This is a design tool that describes the input, processing, and output of a function.

IPO chart

3. When a conversion function is used to convert a real number to an integer, what usually happens to the real number's fractional part?

If the real number has a fractional part, the fractional part will be thrown away.

6.4 In pseudocode, what does the following statement do? Set x = random(1, 100)

It assigns a random number in the range of 1 through 100 to the x variable.

6.5 In pseudocode, what does the following statement do? Display random(1, 20)

It displays a random number in the range of 1 through 20.

5. In pseudocode, this statement causes a function to end and sends a value back to the part of the program that called the function.

Return

6.6 What is the purpose of the Return statement in a function?

The Return statement specifies the value that the function returns to the part of the program that called the function. When the Return statement is executed, it causes the function to terminate and return the specified value.

5. What is the purpose of the stringToInteger and stringToReal functions described in this chapter?

The stringToInteger function accepts a string as an argument, converts it to an Integer, and returns the Integer value.

6.3 Why are library functions like "black boxes"?

The term black box is used to describe any mechanism that accepts input, performs some operation that cannot be seen on the input, and produces output. A library function can be regarded as a black box because you cannot see the code inside the function. The function accepts input, performs an operation on the input, and produces output.

2. Complex mathematical expressions can sometimes be simplified by breaking out part of the expression and putting it in a function.

True

4. In some languages you must use a library function to raise a number to a power.

True

(short answer) 1. What is the difference between a module and a function?

When a module finishes, the program merely returns back to the part of the program that called the module, and execution resumes at that point. When a function finishes, it returns a value back to the part of the program that called it.

6.1 How does a function differ from a module?

When a module finishes, the program merely returns back to the part of the program that called the module, and execution resumes at that point. When a function finishes, it returns a value back to the part of the program that called it.

2. This term describes any mechanism that accepts input, performs some operation that cannot be seen on the input, and produces output.

black box

5. In a case-sensitive comparison, the strings "yoda" and "YODA" are equivalent.

false

(t or f) 1. The code for a library function must appear in a program in order for the program to call the library function.

false (When you call a library function in one of your programs, the compiler or interpreter automatically causes the function to execute, without requiring the function's code to appear in your program.)

4. This part of a function definition is comprised of one or more statements that are executed when the function is called.

function body

3. This part of a function definition specifies the data type of the value that the function returns. 1. header 2. footer 3. body 4. Return statement

function header

6.8 What is a Boolean function?

function that returns either true or false.

2. What three characteristics of a function are described in an IPO chart?

input, processing, and output of a program

6. What is the purpose of the isInteger and isReal functions described in this chapter?

isInteger - to determine whether a string can be converted to an Integer isReal - determine whether a string can be converted to a Real.

(multiple choice) 1. This is a prewritten function that is built into a programming language. 1. standard function 2. library function 3. custom function 4. cafeteria function

library function

10. This is a string inside of another string.

substring

8. This is an example of a data type conversion function in pseudocode.

toReal

9. This type of error occurs when you try to assign a value of one data type to a variable of another data type.

type mismatch error


Related study sets

EAQ Prioritization (Week 3), Week 5 in Class delegation assignment, Week 2 Delegation quiz, EAQ Delegation Wk 2

View Set

The Absolute True Diary of a part time Indian

View Set

Chapter 5, Imperial Reforms and Colonial Protests, 1763-1774

View Set

Public Econ Quizlet 3 Quiz 3, Public Economics Quiz 2, Public Economics: Parts 1 and 2

View Set