...
Programming
October 12, 2023
Operating-Systems
October 12, 2023
Programming
October 12, 2023
Operating-Systems
October 12, 2023

Programming-for-Output-Problems

Question 17
What is the output of this C++ program?

 

A
910
B
920
C
870
D
900
Question 17 Explanation: 
Step-1: In main function, number variable has been initialized to 30.
Step-2: We pass address of number as parameters in the square function. As per the concept of function overloading in C++ the second square function will be executed.
Step-3: –(*y) will be executed first since decrement operator has the higher precedence than multiplication.
*x = (*x) * –(*y);
*x = 30 * 29;
*x = 870
Note: x is a pointer variable and it holds the address of the variable number.
Correct Answer: C
Question 17 Explanation: 
Step-1: In main function, number variable has been initialized to 30.
Step-2: We pass address of number as parameters in the square function. As per the concept of function overloading in C++ the second square function will be executed.
Step-3: –(*y) will be executed first since decrement operator has the higher precedence than multiplication.
*x = (*x) * –(*y);
*x = 30 * 29;
*x = 870
Note: x is a pointer variable and it holds the address of the variable number.
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!