Purchase Solution

Values of the list array after execution via different parameter-passing methods

Not what you're looking for?

Ask Custom Question

I can't seem to find the answer to the following:

Consider the following program written in C syntax:
Void fun (int first, int second) {
First += first;
Second += second;
}
Void main() {
Int list [2] = {1,3};
Fun(list[0], list[1]);
}
For each of the following parameter-passing methods, what are the values of the list array after execution?
a. Passed by value
b. Passed by reference
c. Passed by value-result

Attachments
Purchase this Solution

Solution Summary

Shows the list array values after execution of a C function named 'fun' using three types of parameter passing. Attached as Word.

Solution Preview

I have attached the solution.

Consider the following program written in C syntax:
Void fun (int first, int second) {
First += first;
Second += second;
}
Void main() {
Int list [2] = {1,3};
Fun(list[0], list[1]);
}
For each of the following parameter-passing methods, what are the values of the list array after execution?
a. Passed by value
b. Passed by reference
c. Passed by value-result

Answer (a):- Passed by Value. The code as you have written right now is passing by value.
Void main(){
Int list [2]={1,3} /* It means List[0] = 1 and List[1] = 3*/
Fun(list[0], lis[1]); /* Here we are calling Function 'Fun' and passing parameters. Suppose we pass it by value */
/* Control will now be returned to Function 'Fun' with First = 1 and Second = 3*/
First += First; /* It would amount to First = First + First which would ...

Purchase this Solution


Free BrainMass Quizzes
Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Javscript Basics

Quiz on basics of javascript programming language.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.