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

Eva Peron asked her followers to call her what name? A. Lady of Hope B. Princessa C. Evita D. El Presidente
A cube has a surface area of 181.5 sq. in. What is the length of its sides?
what are some real real world examples of golgi apparatus
how many four-digit numbers are possible in which the leftmost digit is odd, the rightmost digit is even, and all four digits are different
How did the 1803 ruling in Marbury v. Madison affect the balance of power in the federal government? It made the executive branch stronger than the other branch
Who to say love in spanish
appleseed a tech company spends a fixed cost of $1500 to manufacture the wristbands for their new appleseed watch plus $100 per unit manufactured solution
12 liters is about how many quarts
How many elements are found in the chemical formula C3H8O (rubbing alcohol)?
According to the humanistic perspective, anxiety is a result of __________.