Programming
September 30, 2023
Programming-for-Output-Problems
September 30, 2023
Programming
September 30, 2023
Programming-for-Output-Problems
September 30, 2023

Programming-for-Output-Problems

Question 23
If n has 3, then the statement a[++n]=n++;
A
assigns 3 to a[5]
B
assigns 4 to a[5]
C
assigns 4 to a[4]
D
what is assigned is compiler dependent
Question 23 Explanation: 
Given statement consists of three operators which are pre-increment , post-increment and equal to operator. According to operator precedence and associativity, the order of operators evaluation is post-increment,pre-increment and finally equal to operator.
But one variable value is modifying multiple times in the same expression means that behaviour is undefined behaviour which is compiler dependent.
Correct Answer: D
Question 23 Explanation: 
Given statement consists of three operators which are pre-increment , post-increment and equal to operator. According to operator precedence and associativity, the order of operators evaluation is post-increment,pre-increment and finally equal to operator.
But one variable value is modifying multiple times in the same expression means that behaviour is undefined behaviour which is compiler dependent.
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!!