Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1 A parameter in a C++ function is passed by value. Which of following statement is true? I. The value of the real parameter
Question 1 A parameter in a C++ function is passed by value. Which of following statement is true? I. The value of the real parameter is passed to the formal parameter; II. Changing the value of the formal parameter in the function will not change the real parameter; III. Changing the value of the formal parameter in the function will change the real parameter as well. Question 1 options: a. I only b. II only I and II only d. I and III only c. Question 2 A parameter in a C++ function is passed by reference. Which of following statement is true? I. The reference of the real parameter is passed to the formal parameter; II. Changing the value of the formal parameter in the function will not change the real parameter: III. Changing the value of the formal parameter in the function will change the real parameter as well. Question 2 options: a. I only b. II only I and II only d. I and III only c. Question 3 Consider the following expression of integer operation in C++: int m= 15%6; int n= 15/6; What are the values of m and n? Question 3 options: a. 3 b. 3 c. 2 d. 2.5 2.5 2 2.5 2.5 Question 4 Consider the following C++ functions, where a is a global variable. int a = 2; void fl(int b){ b= a + 5; cout =1){ cout =1){cout =0){cout 0){cout 1)? n* factorial(n-1): 1; } int factorial(int n){ return (n>1)? factorial(n)* factorial(n-1): 1; } e. Question 8 Consider the following program segment, where a is an integer constant and b is an integer variable that holds a positive value. int r= 0; int n = b; while (n !=0){rt= a; n--; } Which of the following is a loop invariant for the while loop? Question 8 options: a. r= a(b-1) b. r=b(a-1) r= a + b d. r= ab - 1 e. r= ab c. Question 9 When a C++ program is running, where are global variables allocated? Question 9 options: a. b. in the runtime calling stack at a fixed position it depends which function is called inside main function C. d. Question 10 When a C++ function is executing, where are local variables of the function allocated? Question 10 options: a. in the runtime calling stack before parameters b. at a fixed position in the runtime before parameters and return address d. after the first statement of the function in the runtime calling stack after parameters and return address c. e. Question 11 When a C++ function is called, where are parameters of the function allocated? Question 11 options: a. in the runtime calling stack after return value if its not a void function b. at a fixed position in the runtime stack after local variables d. after the first statement of the function c. Question 12 In a C++ program, where are global variables declared? Question 12 options: a. in the runtime calling stack b. outside of all functions can be anywhere d. inside main function c. Question 13 In a C++ program, where are local variables of a function declared? Question 13 options: a. b. in the runtime calling stack before parameters in the runtime calling stack after parameters and return address can be anywhere inside the function C. d. Question 14 In a C++ function, where are the formal parameters (arguments) of the function declared? Question 14 options: a. b. c. in the runtime calling stack after return value first line inside the block of the function body outside of the function can be anywhere inside the block of the function body in the heading of the function between parenthesis d. e. Question 15 Can a C++ function access the parameter of another function? Question 15 options: a. Yes b. No Question 16 Select the statement that is NOT true about static and dynamic binding. Question 16 options: a. dynamic binding occurs at run time b. static binding occurs at compile time pass by reference is an example of dynamic binding d. pass by reference is an example of static binding c. Question 17 Which of following parameter declaration makes an integer pointer type parameter xp to be passed by reference? Question 17 options: a. b. int* _xp int& xp int* & xp c. d. &int* xp e. *int xp& Question 18 Assume aa is a dynamic array of double type, and has been allocated enough memory to hold 5 double type numbers. Which of following releases the memory used by dynamic array? Question a. release aa[]; b. delete aa[]; delete aa; d. delete [] aa; c
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started