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

How did the pre-Socratic philosophers lay the foundations for science?
What artist painted this picture
What does y equal? 5x+3y=1
Once our dna sends out a signal to make proteins, it's the job of the ________ to receive this genetic message from the dna and to make and transport the requir
a car can travel 96 km. on 8 liters of gas. how far can the car travel on 15vliter of gas ?
Write 0.5 in simplest form
julie has 3/4 quart of fruit juice. she pours the same amount into each of the 4 glasses. which equation represents the fraction of a quart of fruit juice n tha
How many different numbers can be obtained using five binary bits?
is the square root of 36/6 rational
Alison has developed an interest in how the brain controls the body's voluntary action. you suggest that she become a(n) _____ psychologist.