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 of the following statements is true about the composition of the atmosphere? A. The atmospheric conditions are uniformly even as latitude and altitude
pleassssssssssseeeeeeee help me! ASAP
Which side lengths form a right triangle?
A line passes through the point (4,–2) and is perpendicular to the line with the equation y = 2⁄3x + 4. What's the equation of the line?
At the market,7 apples cost $4.55. What is the cost per apple?
HELP ASAP! GIVING BRAINLIEST!! ∆ABC has A(-3, 6), B(2, 1), and C(9, 5) as its vertices. The length of side AB is A) (50)^1/2 B) (65)^1/2 C) (105)^1/2 D) (145)^
Why are nongovernmental organizations important
which two factors of a molecule determine whether or not ti can cross the membrane
natural diasters can have positive effects on an ecosystem. true or false
What is a state legislators most important job​