yogirlsam9524 yogirlsam9524
  • 04-07-2019
  • Computers and Technology
contestada

What is the output of the following program segment?

int x = 0;

++x;

x++;

++x;

x++;

++x;

Respuesta :

PhantomWisdom PhantomWisdom
  • 13-07-2019

Answer:

5

Explanation:

The operator 'x++' is called the post increment operator, it is assign first and then increment.

The operator '++x' is called the pre increment operator, it is increment first  and then increment.

So, both are increment operator which increment the value by one.

initially the value of x is zero,

++x increase the value to 1 and than assign to x.

then, x++ it assign to x first then increment by 1 means x=2

and so on.....

Their are five increment operator are used. so, the result is 5.

Answer Link

Otras preguntas

The theory of plate tectonics explains all of the following except A. earthquakes. B. continental movement. C. volcanoes. D. weathering.
One of the key questions historical criticism attempts to answer is: What were the important conflicts of the time? a. True b. False
Which statement best describes the Sapphic stanza? A Sapphic stanza consists of three lines in which each line has two fewer syllables than the previous one. A
predict the miles traveled in 5 hours at a rate of 189 miles in 3 hours
What would most likely happen if a person increased the amount of saturated fat in his or her diet
12 letter that has to do with farming
What is the purpose of frequency graphs?
The perimeter of a rectangular sandbox is 28ft. The length is six times the width.
Which is not a compound? 8H2 H2O 6CaO 5HCl
People had to pay taxes to provide services for the newcomers. a. Yes b. No