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

what is the slope-intercept form for the equation y-10=3/5(x-5)
What is the point of intersection of two sides of a polygon called?
What is an essential government role in market economies? to control prices and costs to prevent monopolies and collusion to provide luxury items to market good
How is the newton related to other measurement units?
does 72 inches=3 yards yes or no
10x-3=8x-39 show work
of the four river valleys that supported major early civilizations, which one lost one of its major rivers
why are agricultural products hard to grow in north alaska
​Members of the --- are elected on the basis of the state's population at the most recent U.S.census, but each state has an equal number of --- House Senate Sen
Which factor made it more difficult for new immigrants to be assimilated into American society? (A) New immigrants largely favored socialism. (B) New immigrants