Programming
October 12, 2023Operating-Systems
October 12, 2023Programming-for-Output-Problems
Question 17 |
What is the output of this C++ program?
910 | |
920 | |
870 | |
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.
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.
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.
Subscribe
Login
0 Comments