Ask Question
31 July, 15:20

What is the output of the following program segment? int main () { int num = 5; cout << num <<" "; change (num); cout << num << endl; return 0; } void change (int &num) { num = 10; }

+3
Answers (1)
  1. 31 July, 19:05
    0
    The output of the given C+ + language code is as follows:

    Output:

    5 10

    Explanation:

    Description of the given C+ + language code as follows:

    In this code, the main method is defined inside the main method an integer variable num is declared that contains a value that is "5". In this method first, a variable value is printed then a function that is "change" is called then we print function value. In the last, a change method is defined, which contains an integer variable "num" in its parameter, and inside a function num variable another value is defined, that is 10, that's why the first 5 and then 10 value is printed.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “What is the output of the following program segment? int main () { int num = 5; cout ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers