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

Do you like my drawings OwO
Question 8 Ap lang unit 2 progress check MCQ: Which of the following best summarizes the author’s thesis in the passage?
What is commensalism
Which of the following factors best supports the argument in the excerpt?.
The product of −2 and a number x is greater than 30. Whats the solution of the inequality.
Describe the differences between how Borlaug came up with a plant with the traits he wanted with how companies like Monsanto get plants with the traits they wan
what is 1,623 x 2,908? please help
Simplify. 54+4(3/4−1/2)2
Name any three slogans about women rightsany three slogans about women right ​
which city has hosted a major league baseball all-star game