Ask Question

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. 2 January, 00:25
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers