Ask Question
10 May, 12:03

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

+5
Answers (1)
  1. 10 May, 13:02
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers