pumpkin4661 pumpkin4661
  • 14-07-2019
  • Computers and Technology
contestada

What will the following code display?

int number = 6;
cout << ++number << endl;




1. 0

2. 5

3. 7

4. 6

Respuesta :

PhantomWisdom PhantomWisdom
  • 18-07-2019

Answer:

7

Explanation:

The operator '++number' is called the pre increment operator which is used to increment the value by 1 first and then assign.

for example:

int n = 10;

b = ++n;

here, it increase the value of 10 first then assign to b. hence, b assign the value 11.

similarly, in the question:

int number = 6;

after that, the pre increment operator increase the value by one and then assign to number.

it means number assign the value 7 and finally print the value.

Therefore, the answer is 7.

Answer Link

Otras preguntas

What conflicts might they cause for macbeth in the future?
Find the area of the shaded region. Use 3.14 for π. 31.4 sq cm 15.7 sq cm 5 sq cm 675.1 sq cm
How do I know when to use the word sew and when to use the word sow?
How many cups of sugar will she need ?
can someone interpret this? " I cannnot think that we are useless or God would not have created us" thnks.
In an experiment, the enzyme lactase is added to milk in a test tube. The products obtained are glucose and galactose. Which of these CORRECTLY explains the fun
Find the number of possible distinct arrangements using the letters in the word cheer
determine the number of real solutions -4x^2+20x-25=0'
Climate changes can produce various effects in ecosystems. Which of the following is a way that marine ecosystems can be affected by climate warming trends? a.
X=y-7. X+8y=2 Hellplpp helllpppp! Plz!