Multiple Choice Identify the
choice that best completes the statement or answers the question.
|
|
|
1.
|
#include<iostream.h>
// line 1 int perimeter(int, int); //line 2 void main() //line
3 { int length=5 ; //line 4 int width = 2 ; // line
5 int answer, ans ; //line 6 cout << “The perimeter is “
<< perimeter(length, width) << endl; // line 7 answer = perimeter(length,
width) ; // line 8 ans = perimeter(length, width) + perimeter(length, width);
//line 9 }//end main int perimeter(int a , int b ) //line 10 { return
2*a + 2*b ; // line 11 }//end function
Which line starts the function
declaration?
a. | line 7 | b. | line 9 | c. | line
11 | d. | line 8 | e. | line 6 | f. | line
2 | g. | line 10 | h. | line 5 |
|
|
|
2.
|
#include<iostream.h>
// line 1 int perimeter(int, int); //line 2 void main() //line
3 { int length=5 ; //line 4 int width = 2 ; // line
5 int answer, ans ; //line 6 cout << “The perimeter is “
<< perimeter(length, width) << endl; // line 7 answer = perimeter(length,
width) ; // line 8 ans = perimeter(length, width) + perimeter(length, width);
//line 9 }//end main int perimeter(int a , int b ) //line 10 { return
2*a + 2*b ; // line 11 }//end function
Which line contains an actual
parameter?
a. | line 11 | b. | line 7 | c. | line
8 | d. | line 4 | e. | line 5 | f. | line
10 | g. | line 6 | h. | line 9 |
|
|
|
3.
|
#include<iostream.h>
// line 1 int perimeter(int, int); //line 2 void main() //line
3 { int length=5 ; //line 4 int width = 2 ; // line
5 int answer, ans ; //line 6 cout << “The perimeter is “
<< perimeter(length, width) << endl; // line 7 answer = perimeter(length,
width) ; // line 8 ans = perimeter(length, width) + perimeter(length, width);
//line 9 }//end main int perimeter(int a , int b ) //line 10 { return
2*a + 2*b ; // line 11 }//end function
Which line uses a function in an
assignment statement?
a. | line 11 | b. | line 10 | c. | line
8 | d. | line 2 | e. | line 7 | f. | line
5 | g. | line 6 | h. | line 9 |
|
|
|
4.
|
#include<iostream.h>
// line 1 int perimeter(int, int); //line 2 void main() //line
3 { int length=5 ; //line 4 int width = 2 ; // line
5 int answer, ans ; //line 6 cout << “The perimeter is “
<< perimeter(length, width) << endl; // line 7 answer = perimeter(length,
width) ; // line 8 ans = perimeter(length, width) + perimeter(length, width);
//line 9 }//end main int perimeter(int a , int b ) //line 10 { return
2*a + 2*b ; // line 11 }//end function
Which line starts the function
definition?
a. | line 7 | b. | line 5 | c. | line
4 | d. | line 6 | e. | line 8 | f. | line
10 | g. | line 9 | h. | line 11 |
|
|
|
5.
|
According to our style of programming, formal parameters are
a. | located below main(). | b. | none of these | c. | located above
main(). | d. | locate inside main(). |
|
|
|
6.
|
#include<iostream.h>
// line 1 int perimeter(int, int); //line 2 void main() //line
3 { int length=5 ; //line 4 int width = 2 ; // line
5 int answer, ans ; //line 6 cout << “The perimeter is “
<< perimeter(length, width) << endl; // line 7 answer = perimeter(length,
width) ; // line 8 ans = perimeter(length, width) + perimeter(length, width);
//line 9 }//end main int perimeter(int a , int b ) //line 10 { return
2*a + 2*b ; // line 11 }//end function
Which line starts the function
implementation?
a. | line 9 | b. | line 4 | c. | line
5 | d. | line 11 | e. | line 6 | f. | line
10 | g. | line 8 | h. | line 7 |
|
|
|
7.
|
Which is an example of a function being used in an assignment statement?
Assume all declarations are in place and appropriate.
a. | cout << classMidPoint( ucl, ucl ) << endl ; | b. | cout <<
pow(base, power) << endl; | c. | cout << classMidPoint( 7, 11 )
; | d. | answer = sqrt(value1 * value2) ; |
|
|
|
8.
|
#include<iostream.h>
// line 1 int perimeter(int, int); //line 2 void main() //line
3 { int length=5 ; //line 4 int width = 2 ; // line
5 int answer, ans ; //line 6 cout << “The perimeter is “
<< perimeter(length, width) << endl; // line 7 answer = perimeter(length,
width) ; // line 8 ans = perimeter(length, width) + perimeter(length, width);
//line 9 }//end main int perimeter(int a , int b ) //line 10 { return
2*a + 2*b ; // line 11 }//end function
Which line is the function
heading?
a. | line 4 | b. | line 11 | c. | line
5 | d. | line 6 | e. | line 10 | f. | line
8 | g. | line 7 | h. | line 9 |
|
|
|
9.
|
Function prototype is another name for the
a. | function implementation. | b. | function declaration. | c. | function
heading. | d. | function definition. |
|
|
|
10.
|
#include<iostream.h>
// line 1 int perimeter(int, int); //line 2 void main() //line
3 { int length=5 ; //line 4 int width = 2 ; // line
5 int answer, ans ; //line 6 cout << “The perimeter is “
<< perimeter(length, width) << endl; // line 7 answer = perimeter(length,
width) ; // line 8 ans = perimeter(length, width) + perimeter(length, width);
//line 9 }//end main int perimeter(int a , int b ) //line 10 { return
2*a + 2*b ; // line 11 }//end function
Which line contains a formal
parameter?
a. | line 5 | b. | line 9 | c. | line
10 | d. | line 4 | e. | line 6 | f. | line
8 | g. | line 11 | h. | line 7 |
|
|
|
11.
|
#include<iostream.h>
// line 1 int perimeter(int, int); //line 2 void main() //line
3 { int length=5 ; //line 4 int width = 2 ; // line
5 int answer, ans ; //line 6 cout << “The perimeter is “
<< perimeter(length, width) << endl; // line 7 answer = perimeter(length,
width) ; // line 8 if( perimeter(length,width)<100 ); //line 9 }//end
main int perimeter(int a , int b ) //line 10 { return 2*a + 2*b ;
// line 11 }//end function
Which line uses a function in a mathematical
expression.
a. | line 5 | b. | line 8 | c. | line
11 | d. | line 6 | e. | line 7 | f. | line
9 | g. | line 10 | h. | line 2 |
|
|
|
12.
|
A function definition is
a. | located above main(). | b. | located below main(). | c. | locate inside
main(). | d. | none of these |
|
|
|
13.
|
A function declaration is
a. | locate inside main(). | b. | located below main(). | c. | none of
these | d. | located above main(). |
|
|
|
14.
|
According to our style of programming, actual parameters are
a. | located below main(). | b. | none of these | c. | locate inside
main(). | d. | located above main(). |
|
|
|
15.
|
#include<iostream.h>
// line 1 int perimeter(int, int); //line 2 void main() //line
3 { int length=5 ; //line 4 int width = 2 ; // line
5 int answer, ans ; //line 6 cout << “The perimeter is “
<< perimeter(length, width) << endl; // line 7 answer = perimeter(length,
width) ; // line 8 ans = perimeter(length, width) + perimeter(length, width);
//line 9 }//end main int perimeter(int a , int b ) //line 10 { return
2*a + 2*b ; // line 11 }//end function
Which line starts the function
prototype?
a. | line 2 | b. | line 8 | c. | line
9 | d. | line 11 | e. | line 7 | f. | line
6 | g. | line 10 | h. | line 5 |
|
|
|
16.
|
#include<iostream.h>
// line 1 int perimeter(int, int); //line 2 void main() //line
3 { int length=5 ; //line 4 int width = 2 ; // line
5 int answer, ans ; //line 6 cout << “The perimeter is “
<< perimeter(length, width) << endl; // line 7 answer = perimeter(length,
width) ; // line 8 ans = perimeter(length, width) + perimeter(length, width);
//line 9 }//end main int perimeter(int a , int b ) //line 10 { return
2*a + 2*b ; // line 11 }//end function
Which line uses a function in an
output statement?
a. | line 6 | b. | line 11 | c. | line
8 | d. | line 2 | e. | line 7 | f. | line
5 | g. | line 10 | h. | line 9 |
|
|
|
17.
|
A function implementation is
a. | located below main(). | b. | locate inside main(). | c. | none of
these | d. | located above main(). |
|
|
|
18.
|
A function prototype is
a. | located below main(). | b. | locate inside main(). | c. | none of
these | d. | located above main(). |
|
|
|
19.
|
According to our style of programming, actual parameters are
a. | none of these | b. | locate inside main(). | c. | located below
main(). | d. | located above main(). |
|
|
|
20.
|
A function heading is
a. | located below main(). | b. | none of these | c. | located above
main(). | d. | locate inside main(). |
|