OOPS
August 29, 2024OOPS
August 29, 2024OOPS
Question 80 |
Consider the following two C++ programs P1 and P2 and two statements S1 and S2 about the programs :
- S1: P1 prints out 3
S2: P2 prints out 4:2
What can you say about the statement S1 and S2 ?
Code:
Neither S1 nor S2 is true
| |
Only S1 is true
| |
Only S2 is true
| |
Both S1 and S2 are true |
Question 80 Explanation:
The program P1 code consists of function with three parameters integer, pointer and reference variable.
The definition of the function first modifies “i” value by 2 and later by “3” and that modification of the value is automatically reflects in the main program as “c” is reference variable.
The program code P2 will gives the output of 4:5 as the function will take reference variable as parameter and return type also reference object.
The definition of the function first modifies “i” value by 2 and later by “3” and that modification of the value is automatically reflects in the main program as “c” is reference variable.
The program code P2 will gives the output of 4:5 as the function will take reference variable as parameter and return type also reference object.
Correct Answer: B
Question 80 Explanation:
The program P1 code consists of function with three parameters integer, pointer and reference variable.
The definition of the function first modifies “i” value by 2 and later by “3” and that modification of the value is automatically reflects in the main program as “c” is reference variable.
The program code P2 will gives the output of 4:5 as the function will take reference variable as parameter and return type also reference object.
The definition of the function first modifies “i” value by 2 and later by “3” and that modification of the value is automatically reflects in the main program as “c” is reference variable.
The program code P2 will gives the output of 4:5 as the function will take reference variable as parameter and return type also reference object.