Exam 2 Flashcards
(93 cards)
A void function can be used in an assignment
False
It is acceptable to have both call by value and call by reference parameters in a function?
True
In a function with call-by-reference parameters, the values of the actual arguments are called through the function?
False. The memory address is called
Testing a function or program using test values that are at or near the values that change the outcome of the program is known as using _____ values?
Boundary
It is illegal to call other functions from inside a function definition?
False
A stub is a function that is completely defined and well tested?
False
A simplified main program for testing is called?
a driver
In a function with call-by-reference parameters, any changes to the formal parameters will change the actual arguments passed to the function?
True
void something(int a, int& b)
{ int c; c= a + 2; a = a*3; b = c+a; }
r =1;
s=2;
t=3;
something(t,s);
cout «_space;r «_space;’ ‘ «_space;s «_space;’ ‘ «_space;t «_space;endl;
1 14 3
If you were to write a function for displaying the cost of an item to the screen. which function prototype would be appropriate?
void display(); void display(float myCost); int display(float myCost); float display();
void display(float myCost);
In the following function, what is passed to the first parameter?
void f1(int& value1, int value2);
int x,y;
f1(x,y);
- The value of x
- Nothing, it is a void function
- The value of y
- The variable x(or its memory location)
- The variable x(or its memory location)
Functions can return at most one value
true
the following is legal in a void function
return;
True
If a function needs to modify more than one variable, it must be a…
Call by reference function
a void function may not be used in an output statement
true
if you write a function that should use call-by-reference, but forget to include the ampersand..
the program will run with incorrect results. it will pass it with a call by value
Given the following function definitions and program fragments, what is the output?
void f2(int &z, int &q);
int x=3, y=4;
f2(y,x);
cout «_space;x «_space;” “ «_space;y «_space;endl;
3 4
Testing your program should be done as each ____ is developed
function
Call by reference parameters are passing
The address of the actual argument
Call by reference should be used when the function needs to change __________
The value of one or more arguments
A simplified version of a function which is used to test the main program is called a
stub
void shift(int& a, int&b) { a = b; b = a; }
what is the output after the following:
int first = 0, second =10;
shift (first, second);
cout «_space;first «_space;” “ «_space;second «_space;endl;
10 10
int myInt; float myFloat; char ch; void someFunction(int & first, float second, char third);
Which is invalid?
someFunction(1,2.0,ch);
someFunction(myInt, myFloat, ch);
someFunction(myInt,2.0,’c’);
someFunction(myInt,myFloat,’1’);
someFunction(1,2.0,ch);
A void function can return any value
False