0% found this document useful (0 votes)
22 views5 pages

Final Test

Uploaded by

abdelrahmansendo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views5 pages

Final Test

Uploaded by

abdelrahmansendo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

FINAL TEST BANK

1. Which of the following is the correct function definition header for the getAge function

which is a member of the person class?

a. int getAge();

b. int getAge()

c. int Person:getAge()

d. int Person::getAge()

2. The line of code that will declare an array and initialize it is:

a. int list [6] = {4,7,8,2,9,5};

b. int list [6] {4,7,8,2,9,5};

c. int list [6] = (4,7,8,2,9,5);

d. int list [6] (4,7,8,2,9,5);

3. Which of the following is true for a void function?

a. There cannot be a return statement

b. The value of void should be returned

c. The value of 0 should be returned

d. Nothing is returned
4. What is wrong with the following recursive function? It should print out an array

backwards.

void print ( int array [], int start, int size)

If (start == size )

return;

else

Print (array, start +1, size);

Cout << array [start] << endl;

a. Infinite recursion

b. The stopping condition is wrong

c. The recursive call is wrong

d. Nothing

5. Which of the following would you use in a function prototype for a formal parameter

representing an array that will be changed by the function?

a. float[ ]

b. float [SIZE]

c. float&[ ]

d. const float [ ]
6. Given the following structure definition, what is the correct way to initialize a variable

called today?

struct DateType

int day;

int month;

int year;

a. DateType today(1,1,2000);

b. DateType today = (1,1,2000);

c. DateType today = {1,1,2000);

d. DateType today = {1,1,2000,0);

7. If you try to solve a problem recursively, you should:

a. find all the stopping cases and the values if needed at that case.

b. find a recursive call that will lead towards one of the stopping cases.

c. All of the above.

d. None of the above.

8. What is the output of the following code, given in the definition below?

int a = 7, b = 12;

Tester (a, b);

Cout << a << “ “ << b;

Void tester (int m, int &n)

{
N = n - 2 * m;

m = 2 * m;

a. 7 -2

b. 7 12

c. 14 -2

d. 14 12

9. Which of the following assigns to p1 the pointer to the address value?

a. *p1 = value;

b. P1 = value;

c. p1=&value;

d. &p1 = *value;

10. When should a parameter be a value parameter?

a. When the parameter is carrying information into the function that does not have to

be returned.

b. When the parameter is carrying information into the function that may be changed

and the new value should be returned

c. When the information is to be returned from the function using the parameter.

d. When the parameter is an output parameter

11. To assign values to a structure variable, you use the

a. Equals operator
b. Assignments operator

c. Extraction operator

d. Less than operator

12. What is the output of the following code, given in the definition below?

int x =5, y = 2;

y = mixUp (x, y);

cout << x;

int mixUp (int &p, int t) //function definition

p = p * t;

return p + 1;

a) 5

b) 6

c) 10

d) 11

You might also like