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

The exclusionary rule was applied to all levels of government by the supreme court justices in ________.
According to the Declaration of Independence, when should the people have the right to change their government? A. When a government wants to raise taxes B. Whe
One tablespoon of peanut butter has a mass of 17.0 g. it is combusted in a calorimeter whose heat capacity is 110 kj/°c. the temperature of the calorimeter ris
Two way Frequency table question
Which number contains a sentence error? 1.Mike enjoyed learning Spanish, so he signed up to help teach the language to police officers. 2.Mike enjoyed learning
Write an equation of the line that has a slope of 2 and y-intercept 1 in slope-intercept form.
Factor out the coefficient of the variable. -3.6z-10.8
Find d arithmetic mean of _10 and _5
For which bacterial genus is mannitol salt agar selective for?
Write words to match expression 3+(4x12)