Ask Question
24 August, 02:16

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

+2
Answers (1)
  1. 24 August, 04:19
    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?
Get 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 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