Ask Question

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; }

+2
Answers (1)
  1. 13 July, 02:40
    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?
Find an answer to your question 👍 “What is the output of the following program segment? int main () { int num = 5; 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