What will be the output of the following?
int x = 3;n = 4 ;
x=++n;
x=x++;
Answers
Answered by
0
x= 4
x= 4,4+1=5,5+1=6,6+1=7.............n
x= 4,4+1=5,5+1=6,6+1=7.............n
Answered by
0
The output of the following int x = 3;n = 4;
The output of the following code comes out to be 5.
Explanation:
It deals with post-and pre-increment operators.
The pre-increment operator increments the value first and then uses it in the expression. It follows the change-then-use rule.
The post-increment operator first uses the value in the expression and then increments it. It follows the use-then-change rule.
x becomes 5 after pre-incrementing from n and then it is post incremented.
When it is printed, the output comes out to be 5. Also it moves on when the value increases.
Learn More About output of the following:
Give the output of the following: int a=0,b=30,c=40; a=--b+c++ + b; system.out.print(''a='' + a);
https://brainly.in/question/1191193
Similar questions
Biology,
7 months ago
Computer Science,
7 months ago
English,
7 months ago
Math,
1 year ago
Physics,
1 year ago