Computer Science, asked by evasidhani6962, 1 year ago

What will be the output of the following?
int x = 3;n = 4 ;
x=++n;
x=x++;

Answers

Answered by mohit9233
0
x= 4
x= 4,4+1=5,5+1=6,6+1=7.............n
Answered by kingofself
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