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

Which state official defends the state in a lawsuit?
PLEASE HELP WITH WORK INCLUDED
Eating foods with sufficient amounts of______ will help keep your eyes working correctly.
what is the electoral college?
Which ordered pair is a solution to this equation? (x+3)y=14(x+3)y=14 (5, 2)(5, 2) (3, 2)(3, 2) (11, 1)(11, 1) (7, 2)
Our product is equal to 6+2 what factors are we
60 minutes is 20% of ? minute s
How were the deep ravines and rock steps of the Alps formed? A. Thicker ice and faster flowing ice B. Slow ice melt due to low temperatures C. Thin layers of ic
Which of the following is one way that the circulatory system helps maintain body temperature? A. carrying heat around the body B. controlling the flow
Which aspects of Sikhism did the five Ks most Reflect?