Ask Question

What will the following code display?

int number = 6;

cout << + +number << endl;

1. 0

2. 5

3. 7

4. 6

+4
Answers (1)
  1. 22 July, 00:36
    0
    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What will the following code display? int number = 6; 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