Ask Question
13 September, 20:54

Consider the function definition void Demo (int& intVal, float floatVal) { intVal = intVal * 2; floatVal = float (intVal) + 3.5; } Suppose that the caller has variables myInt and myFloat whose values are 20 and 4.8, respectively. What are the values of myInt and myFloat after return from the following function call? Demo (myInt, myFloat);

+4
Answers (1)
  1. 13 September, 21:11
    0
    myInt=40

    myFloat=4.8

    Explanation:

    First look at the function definition. It has two arguments intVal is passed by reference while floatVal is passed by value. So the changes done on the myInt variable will be reflected on the original argument because when a variable is passed by reference the the changes are reflected on the original argument but when a variable is passed by value the function created a duplicate copy of it and work on them so changes are not reflected on the original argument. So myInt will get doubled while myFloat will remain the same.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Consider the function definition void Demo (int& intVal, float floatVal) { intVal = intVal * 2; floatVal = float (intVal) + 3.5; } Suppose ...” 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