Professional Documents
Culture Documents
2 15
3 10
4 20
5 20
6 20
7 (Bonus) 10
Total 100 + 10
1
Question 1 ( 15 points)
Question 2 ( 15 points)
2
Question 4 ( 20 points)
3
Question 5 (20 points)
Write the C++ statements for each of the following operations
Operation C++ statement(s)
4
Question 6 ( 20 points)
5
Question 7 ( 10 points) (Bonus)
Select ( make it underlined bold) the correct answer from the following:
a. Self referring
b. Recursive
c. Local
d. Anonymous
2. What does the following code do?
int *p;
p = new int;
a. Allocates an integer memory location called p.
b. allocates an integer memory location and save the address in p.
c. changes the type of p to be of type in not pointer.
d. Deallocates an integer called p from memory.
The following code contains portions of a C++ program. They are assumed to exist inside a proper
main function. There are no syntax errors in the code. Answer the questions accordingly.
3. What is wrong with the functionality of the following C++ code?
//This code is supposed to create a 2D array of size 5x5
//and initialize its contents to some numbers (doesn’t matter)
//except that one of diagonals must be set to zero
Good Luck
6