Ask Question
7 December, 14:52

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

+1
Answers (1)
  1. 7 December, 18:36
    0
    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “What will the following code display? int number = 6 int x = 0; x = - -number; cout ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers