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

Explain each expression as used in the passage.1. The best single food​
Hemophilia is an X-linked recessive disorder that is passed through generations and can be traced by using a pedigree.In the pedigree that is shown, which repre
That yogurt smells badly
Question 4 The Majority Leader is elected by the political party with the most Senators. A) True B) False
3.Samy withdrew 1/4 of his savings from the bank. He spent $450 of it and had $150 left. How much was his total savings in the bank at first?
Pls answer thissssssss
I have a quick geometry question! Thank you!
What are the solutions of the equation (x 2)2 – 2(x 2) – 15 = 0? use u substitution to solve.
If you wanted to explain how trees use photosynthesis to produce oxygen, what type of visual aid would you use? Group of answer choices a chart showing how many
Towering bulwarks are popular rides at amusement parks. True or False