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

What will the following code display?

int number = 6
int x = 0;
x = --number;
cout << x << endl;




1. 7

2. 6

3. 5

4. 0

Respuesta :

PhantomWisdom PhantomWisdom
  • 17-07-2019

Answer:

5

Explanation:

The operator '--number', it is a pre decrement operator which decrement first and then assign. It decrement the value by 1.

initially the number is 6.

x is 0.

then, x = --number;

it decrement the number by 1 first and then assign to x.

so, x assign the value 5.

finally, print the value.

Therefore, the answer is 5.  

Answer Link

Otras preguntas

please give correct answer!
does the moon emit radiation
Tell whether the angle is adjacent or vertical. Then find the value of x
Randal is a 17-year-old whose parents have left him mostly on his own for several years. they leave for days on end to drink and gamble, leaving no food or assi
An economic impact immediately following World War I in Europe was A expansion of trade B major inflation C an economic boom D a shift to a common currency
The production of releasing and inhibiting hormones by the hypothalamus are needed to control the _____. anterior pituitary gland. subthalamus. posterior pituit
How many senate votes does it take to approve a supreme court justice?
Henry has just moved to England and is trying to continue his lawn care business. He needs to buy gas for his lawnmower. He has a 5 gallon jug and then 2 3 qua
which relation is a function?
What is 6.34+3.95 using benchmark to estimate