bnshelton4690 bnshelton4690
  • 04-07-2019
  • Computers and Technology
contestada

What is the output after the following code executes?

int x=10; if ( ++x > 10 ) {

x = 13;

}

cout << x;

Respuesta :

PhantomWisdom PhantomWisdom
  • 12-07-2019

Answer:

13

Explanation:

First understand the meaning of ++x, it is a pre-increment operator.

it means, it increase the value first than assign to the variable.

For example:

x=10

then after executing  ++x, the value of x is 11.

it increase the value and assign to x.

In the question:

The value of x is 10. After that, program moves to the if condition and check for condition (++x > 10) means (11 > 10) condition true.

then, 13 assign to x.

After that value of x is printed as 13.

Answer Link

Otras preguntas

Write the equation whose roots are 6 and 1, and whose leading coefficient is 4.
Convert 7.82km to centimeter .​
Unsalted butter in packs are known to be normally distributed. A sample of those packs of butter had masses, measured to the nearest gram, as follows. 219, 226,
A car with a velocity of 30 mph right applying its brakes. An object with a velocity of 10 m/s to the left and forces of 10 N nght and S N left acting on it An
(c) In other words, who do you think controlled these countries after the Ottomans? 1
how do I learn spanish
why does a bird egg need to be poruos​
explain nutrition in biology​
Unsalted butter in packs are known to be normally distributed. A sample of those packs of butter had masses, measured to the nearest gram, as follows. 219, 226,
8 pounds + 12.6 oz + 23 pennies = How many pennies??