Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose that the caller has variables myInt and myFloat whose values are 20 and

ID: 3780045 • Letter: S

Question

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) myint = 20 and myFloat = 43.5 myint = 40 and myFloat = 48 myint = 20 and myFloat = 48 myint = 40 and myFloat = 43.5 none of the above In C++ terminology, the statement float windSpeed; is a declaration but not a definition of windSpeed. is a definition but not a declaration of windSpeed. is both declaration and a definition of windSpeed. is neither a declaration and a definition of windSpeed. Is the following function, the declaration of beta includes an initialization. void SomeFunc(int alpha) {static int beta = 25; ...} which of the following statements about beta is false? It is initialized once only, the first time the function is called. It is initialized each time the function is called. It cannot be reassigned a different value within the function. a and c above. b and c above. True or False? Given the declaration int beta[20]; the expression beta[3] accesses the third component of the array. True o False? The array declared as int bowlingScore[6][12]; contains 72 int components

Explanation / Answer

21. Answer - There can be two answers depending on the situation of the program on type of calling :

*** Call by Value : Then answer will be the Option (C) - myInt = 20 and myFloat = 4.8, because in value changes are remains in the local scope of the called method until unless there is a return statement to push values back to the caller method.

*** Call by Reference : Then answer will be Option (E) - none of the above, because in the parameters of the method contains the memory location reference like (demo (&a,&b)). So , now if we call this program from demo(a,b) in this we are passing the memory reference not the actual value which enables the changes to be pushed to variable directly as formal and actual arguments are pointing to same memory reference. So it does not require the return statement to send back the processed or changed values.

22. Answer - (is a declaration but not a definition of windSpeed)

Reason or Explaination : When we write (float windSpeed), it means we are assigning a memory location to the new variable with name which actually is called as declaration of variable. When we will assign some value to this variable then the value will be kept in the assigned memory locaiton during declaration.

23. Answer - It is initialized each time when the function is called.

Reason or Explaination : As the variable we are talking about is local to the method in local scope, so whenever we will call the method it will be reinitialized. As when we make a call to method , it gets a different stack of memory for processing to store local scoped variables. So now as soon as the method execution is complete the stack will vanished and memory allocated will be collected by Garbage Collector. So, next time when function is again called it will be re-initialized.

24. Answer : False

Reason or Explaination: The statement beta[3] will access the 4th element of the array as the index of the array elements starts from 0 while performing any operations on the array elements.

25. Answer: True

Reason or Explaination: It is because the declared two dimensional array has property like (array [rows] [columns]). So now in the given question , as the property there will be 6 rows and each row will have 12 columns.

Hence Proved , by mathematical calculation that it will have 72 components.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote