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

need answer asap please
help ME PLEASE HELP ME I HATE MATH I HATE IT YOU DONT NEED TO EXPLAIN IT I JUST NEED AN ANSWER
PLEASE HELP ME!!! WHAT FIGURATIVE LANGUAGE IS THIS: “We lay down our arms so we can reach out our arms to one another.”
A car is traveling at 25 miles per hour on a residential street. About how many feet does it travel per second?
Avery got on the bus at 1:25 P.M. The trip took 74 minutes. Then she walked for 61 minutes to get home. At what time did Avery arrive at home?
What does "Food supply constant" mean with animals?
find the volume of a 2by2​
The increase in white collar, service, and professional sector jobs following WWII can be attributed to which of the following causes? an economic recession fol
Which organism is the producer in the food chain containing salmon, seal, algae, and polar bear? A. salmon B. seal C. algae D. polar bear
Help me anyone please