Deck 4: Procedural Abstraction and Functions That Return a Value
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/51
Play
Full screen (f)
Deck 4: Procedural Abstraction and Functions That Return a Value
1
A problem-solving approach that starts with the big problem and breaks it down into smaller pieces is called _________________.
top-down approach
2
The black box analagy demonstrates the concept of _________________.
information hiding or procedural abstraction
3
When you want to use a function in your program,you would make a function __________.
call or invocation
4
The ______________ describes how the function will work.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
5
Converting from one type to another is called ______________.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
6
Algorithms are typically described in ________________.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
7
the parameter names are mandatory in the function header
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
8
Functions may have multiple return statements.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
9
the parameters listed in the function declaration are considered global variables
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
10
it is possible to have a function that has no parameters
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
11
A function may return more than one item
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
12
#include is known as an ___________________.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
13
In the following function declaration,the variable size is known as a _________________.
int myFunction int size);
int myFunction int size);
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
14
The absolute value function abs is located in the _________ library.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
15
pow2,3)is the same as pow3,2).
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
16
Write the code to convert the value in an integer variable named count to a double._____________________.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
17
function naming rules follow variable naming rules
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
18
the types of parameters are optional in the function declaration
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
19
variables that are declared outside of any function body or parameter list are considered global.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
20
Every include directive must be followed by using namespace std;
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
21
What is the value of the following?
Floor4.999)+ ceil2.0)
A)6.999
B)7.0
C)6.0
D)8.0
Floor4.999)+ ceil2.0)
A)6.999
B)7.0
C)6.0
D)8.0
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
22
Constant variables that might be used in different functions should be _________
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
23
Multiple arguments to a function are separated by
A)comments
B)semicolons
C)colons
D)commas
E)periods
A)comments
B)semicolons
C)colons
D)commas
E)periods
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
24
If you need to write a function that will compute the cost of some candy,where each piece costs 25 cents,which would be an appropriate function declaration?
A)int calculateCostchar name);
B)char calculateCostint count);
C)int calculateCost int count;
D)int calculateCostint count);
A)int calculateCostchar name);
B)char calculateCostint count);
C)int calculateCost int count;
D)int calculateCostint count);
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
25
using namespace std; tells the compiler
A)where to get the definitions of certain objects variables)
B)where your program is located
C)what language to use for input and output
D)nothing
A)where to get the definitions of certain objects variables)
B)where your program is located
C)what language to use for input and output
D)nothing
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
26
When overloading a function,what must be true?
A)The names should be different with the same number and/or types of parameters.
B)The names should be the same with different number and/or types of parameters.
C)The names should be different with different number and/or types of parameters.
D)The names should be the same with the same number and/or types of parameters.
A)The names should be different with the same number and/or types of parameters.
B)The names should be the same with different number and/or types of parameters.
C)The names should be different with different number and/or types of parameters.
D)The names should be the same with the same number and/or types of parameters.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
27
What is the output of the following program fragment?
Cout << static_cast3)/4 << endl;
A)3
B)0.5
C)0
D)0.75
Cout << static_cast
A)3
B)0.5
C)0
D)0.75
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
28
What is the value of the following?
Sqrtsqrtpow2,4)));
A)1
B)2
C)4
D)16
Sqrtsqrtpow2,4)));
A)1
B)2
C)4
D)16
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
29
What is the output of the following program fragment?
Cout << pow4,2)<< endl;
A)4
B)2
C)8
D)16
Cout << pow4,2)<< endl;
A)4
B)2
C)8
D)16
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
30
If the variable x has the original value of 3.4,what is the value in x after the following?
Cout << static_castx);
A)3.4
B)4
C)unknown
D)3
Cout << static_cast
A)3.4
B)4
C)unknown
D)3
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
31
The expression static_cast3)is called a
A)type cast
B)nultiplier
C)doubler
D)polymorphism
A)type cast
B)nultiplier
C)doubler
D)polymorphism
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
32
The _________ of a variable is where that variable can be used.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
33
If you have the two functions as shown,
Int someFunctionint value);
Float someFunctionfloat value);
And a variable x,which is a double,which function is called by the following statement?
Cout << someFunctionx);
A)void someFunctionint value);
B)void someFunctionfloat value);
C)Nothing,it is a syntax error
D)both functions are called
Int someFunctionint value);
Float someFunctionfloat value);
And a variable x,which is a double,which function is called by the following statement?
Cout << someFunctionx);
A)void someFunctionint value);
B)void someFunctionfloat value);
C)Nothing,it is a syntax error
D)both functions are called
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
34
the fabsdouble num)function
A)returns the most fabulous number
B)returns the largest whole number <= num
C)returns the negative value of num
D)returns the absolute value of num
A)returns the most fabulous number
B)returns the largest whole number <= num
C)returns the negative value of num
D)returns the absolute value of num
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
35
What is the value returned by the following function?
Int function)
{
Int value = 35;
Return value + 5;
Value += 10;
}
A)35
B)40
C)50
D)10
Int function)
{
Int value = 35;
Return value + 5;
Value += 10;
}
A)35
B)40
C)50
D)10
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
36
The functions pow),sqrt),and fabs)are found in which include file?
A)cstdlib
B)cmath
C)iostream
D)regular
A)cstdlib
B)cmath
C)iostream
D)regular
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
37
What is the output of the following program fragment?
Cout << static_cast3/4)<< endl;
A)3
B)0.5
C)0.0
D)0.75
Cout << static_cast
A)3
B)0.5
C)0.0
D)0.75
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
38
Using functions in a program is known as
A)data abstraction
B)procedural abstraction
C)poor programming style
D)calculus
A)data abstraction
B)procedural abstraction
C)poor programming style
D)calculus
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
39
What is the value of x after the following code fragment executes?
Float x = 36.0;
X = sqrtx);
A)36.0
B)6.0
C)3.0
D)2.456
Float x = 36.0;
X = sqrtx);
A)36.0
B)6.0
C)3.0
D)2.456
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
40
Varibles that are declared inside a function are said to be _________ to that function.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
41
If you have the following variable declaration in your program,
Const int SIZE=34;
Then which of the following statements are legal?
A)SIZE ++;
B)x = SIZE--;
C)cout << SIZE;
D)cin >> SIZE;
Const int SIZE=34;
Then which of the following statements are legal?
A)SIZE ++;
B)x = SIZE--;
C)cout << SIZE;
D)cin >> SIZE;
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
42
Which of the following are valid function calls to the pow function?
A)powint x,int y);
B)pow2);
C)pow1.1,3.0);
D)double pow1.1,3.0);
A)powint x,int y);
B)pow2);
C)pow1.1,3.0);
D)double pow1.1,3.0);
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
43
Which of the following are not legal function declarations?
A)int ave3int a,int b,int c);
B)int 3aveint a,int b,intc);
C)int ave3int,int,int);
D)int ave_3int a1,int a2,int a3);
A)int ave3int a,int b,int c);
B)int 3aveint a,int b,intc);
C)int ave3int,int,int);
D)int ave_3int a1,int a2,int a3);
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
44
When a variable is local to a function,we say that it has ___ of the function
A)value
B)constance
C)scope
D)locality
A)value
B)constance
C)scope
D)locality
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
45
Information Hiding is analogous to using
A)an algorithmic design
B)a black-box methodology
C)formal parameters
D)actual parameters
A)an algorithmic design
B)a black-box methodology
C)formal parameters
D)actual parameters
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
46
What is the output of the following function call?
//function body
Int factorialint n)
{
Int product=0;
Whilen > 0)
{
Product = product * n;
N-;
}
Return product;
}
//function call
Cout << factorial4);
A)4
B)0
C)24
D)48
//function body
Int factorialint n)
{
Int product=0;
Whilen > 0)
{
Product = product * n;
N-;
}
Return product;
}
//function call
Cout << factorial4);
A)4
B)0
C)24
D)48
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
47
What is the value of i after the following function call?
//function definition
Int doSomethingint value)
{
Value = 35;
Return value;
Value = 13
}
//fragment of main program
Int i=0;
Cout << doSomethingi);
A)13
B)35
C)48
D)0
//function definition
Int doSomethingint value)
{
Value = 35;
Return value;
Value = 13
}
//fragment of main program
Int i=0;
Cout << doSomethingi);
A)13
B)35
C)48
D)0
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
48
When the function below is called,the _____ of the actual parameters is passed to the function definition.
Double sqrtdouble value);
A)name
B)value
C)address
D)scope
Double sqrtdouble value);
A)name
B)value
C)address
D)scope
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
49
In the function declaration shown,the mechanism used to call this function is known as:
Double powdouble base,double exp);
A)pass by name
B)pass by value
C)pass by name
D)call by name
Double powdouble base,double exp);
A)pass by name
B)pass by value
C)pass by name
D)call by name
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
50
What is the output of the following code fragement?
Double size,volume=16.0;
Size = sqrtsqrtvolume))/ 3;
Cout.setfios::fixed)
Cout.setfios::showpoint);
Cout.precision2);
Cout << size;
A)0.67
B)0.6666667
C)0.00
D)0
Double size,volume=16.0;
Size = sqrtsqrtvolume))/ 3;
Cout.setfios::fixed)
Cout.setfios::showpoint);
Cout.precision2);
Cout << size;
A)0.67
B)0.6666667
C)0.00
D)0
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
51
Which of the following functions is a properly overloaded function of the following?
Int doSomethingint first,float second);
A)float doSomethingint first,float second);
B)int doSomething int next,float last);
C)int doSomethingint first,int second,float third);
D)int doSomeint first,float second);
Int doSomethingint first,float second);
A)float doSomethingint first,float second);
B)int doSomething int next,float last);
C)int doSomethingint first,int second,float third);
D)int doSomeint first,float second);
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck