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 are the definitions to 'law of soil' and 'law of blood' ? what does it mean ? please help me .
what is the importance of prehistory
What is extrinsic motivation? motivation that is stated directly in the text through the author's narration motivation that comes from an internal desire to do
Which is an implied or indirect reference found in literature? A. a point of view B. a themeC. an allusionD. a symbol
How did Athenians avoid major political upheavals?
Which of the following best describes why Africans could have sold other Africans into slavery? A. They thought of themselves in terms of tribal groups, such as
Most of the evidence we have about early humans comes from _____.
should eighth be capitalized if use in a sentence
7e−4=31 solve for e.
How did revolutionary thinkers ideas change the perception of independence