Deck 4: Procedural Abstraction and Functions That Return a Value

ملء الشاشة (f)
exit full mode
سؤال
function naming rules follow variable naming rules
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
#include is known as an ___________________.
سؤال
Functions may have multiple return statements.
سؤال
the types of parameters are optional in the function declaration
سؤال
The absolute value function abs is located in the _________ library.
سؤال
variables that are declared outside of any function body or parameter list are considered global.
سؤال
What is the output produced by the following code fragment?
int i = 3;
cout << "The value of i is " << sqrtpowi,4.0)) << endl;
سؤال
The black box analagy demonstrates the concept of _________________.
سؤال
When you want to use a function in your program, you would make a function __________.
سؤال
The ______________ describes how the function will work.
سؤال
What is the value of pow2,sqrt9.0)+ceil0.99)))? ______________
سؤال
pow2,3) is the same as pow3,2).
سؤال
it is possible to have a function that has no parameters
سؤال
Every include directive must be followed by using namespace std;
سؤال
In the following function declaration, the variable size is known as a _________________.
int myFunction int size);
سؤال
Write the code to convert the value in an integer variable named count to a double. _____________________.
سؤال
the parameters listed in the function declaration are considered global variables
سؤال
Converting from one type to another is called ______________.
سؤال
the parameter names are mandatory in the function header
سؤال
A function may return more than one item
سؤال
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
سؤال
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
سؤال
The _________ of a variable is where that variable can be used.
سؤال
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
سؤال
A problem-solving approach that starts with the big problem and breaks it down into smaller pieces is called _________________.
سؤال
The expression static_cast3) is called a

A) type cast
B) nultiplier
C) doubler
D) polymorphism
سؤال
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.
سؤال
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
سؤال
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
سؤال
The functions pow), sqrt), and fabs) are found in which include file?

A) cstdlib
B) cmath
C) iostream
D) regular
سؤال
What is the value of the following?
Floor4.999) + ceil2.0)

A) 6.999
B) 7.0
C) 6.0
D) 8.0
سؤال
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
سؤال
What is the output of the following program fragment?
Cout << pow4,2) << endl;

A) 4
B) 2
C) 8
D) 16
سؤال
Varibles that are declared inside a function are said to be _________ to that function.
سؤال
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);
سؤال
Constant variables that might be used in different functions should be _________
سؤال
Multiple arguments to a function are separated by

A) comments
B) semicolons
C) colons
D) commas
E) periods
سؤال
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
سؤال
Algorithms are typically described in ________________.
سؤال
What is the output of the following program fragment?
Cout << static_cast3)/4 << endl;

A) 3
B) 0.5
C) 0
D) 0.75
سؤال
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
سؤال
Using functions in a program is known as

A) data abstraction
B) procedural abstraction
C) poor programming style
D) calculus
سؤال
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
سؤال
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;
سؤال
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);
سؤال
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
سؤال
What is the value of the following?
Sqrtsqrtpow2,4)));

A) 1
B) 2
C) 4
D) 16
سؤال
Information Hiding is analogous to using

A) an algorithmic design
B) a black-box methodology
C) formal parameters
D) actual parameters
سؤال
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);
سؤال
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
سؤال
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);
سؤال
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
سؤال
When a variable is local to a function, we say that it has ___ of the function

A) value
B) constance
C) scope
D) locality
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/53
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 4: Procedural Abstraction and Functions That Return a Value
1
function naming rules follow variable naming rules
True
2
#include is known as an ___________________.
include directive
3
Functions may have multiple return statements.
True
Fill In the Blank
4
the types of parameters are optional in the function declaration
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
5
The absolute value function abs is located in the _________ library.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
6
variables that are declared outside of any function body or parameter list are considered global.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
7
What is the output produced by the following code fragment?
int i = 3;
cout << "The value of i is " << sqrtpowi,4.0)) << endl;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
8
The black box analagy demonstrates the concept of _________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
9
When you want to use a function in your program, you would make a function __________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
10
The ______________ describes how the function will work.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
11
What is the value of pow2,sqrt9.0)+ceil0.99)))? ______________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
12
pow2,3) is the same as pow3,2).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
13
it is possible to have a function that has no parameters
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
14
Every include directive must be followed by using namespace std;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
15
In the following function declaration, the variable size is known as a _________________.
int myFunction int size);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
16
Write the code to convert the value in an integer variable named count to a double. _____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
17
the parameters listed in the function declaration are considered global variables
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
18
Converting from one type to another is called ______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
19
the parameter names are mandatory in the function header
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
20
A function may return more than one item
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
21
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
22
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
23
The _________ of a variable is where that variable can be used.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
24
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
25
A problem-solving approach that starts with the big problem and breaks it down into smaller pieces is called _________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
26
The expression static_cast3) is called a

A) type cast
B) nultiplier
C) doubler
D) polymorphism
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
27
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
28
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
29
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
30
The functions pow), sqrt), and fabs) are found in which include file?

A) cstdlib
B) cmath
C) iostream
D) regular
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
31
What is the value of the following?
Floor4.999) + ceil2.0)

A) 6.999
B) 7.0
C) 6.0
D) 8.0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
32
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
33
What is the output of the following program fragment?
Cout << pow4,2) << endl;

A) 4
B) 2
C) 8
D) 16
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
34
Varibles that are declared inside a function are said to be _________ to that function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
35
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
36
Constant variables that might be used in different functions should be _________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
37
Multiple arguments to a function are separated by

A) comments
B) semicolons
C) colons
D) commas
E) periods
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
38
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
39
Algorithms are typically described in ________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
40
What is the output of the following program fragment?
Cout << static_cast3)/4 << endl;

A) 3
B) 0.5
C) 0
D) 0.75
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
41
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
42
Using functions in a program is known as

A) data abstraction
B) procedural abstraction
C) poor programming style
D) calculus
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
43
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
44
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;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
45
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
46
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
47
What is the value of the following?
Sqrtsqrtpow2,4)));

A) 1
B) 2
C) 4
D) 16
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
48
Information Hiding is analogous to using

A) an algorithmic design
B) a black-box methodology
C) formal parameters
D) actual parameters
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
49
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
50
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
51
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
52
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
53
When a variable is local to a function, we say that it has ___ of the function

A) value
B) constance
C) scope
D) locality
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.