What are arguments for and against a user program building


Question 1. What are arguments for and against a user program building additional definitions for existing operators, as can be done in Python and C++? Do you think such user-defined operator overloading is good or bad? Support your answer.

Question 2. Consider the following program written in C syntax:

void swap(int a, int b) {
int temp;
temp = a;
a b;
b temp;
void main()
int value = 2, list[5] (1, 3, 5, 7, 9};
swap(value, list[0]);
swap(list[0], list[1]);
swap(value, list[value]);

For each of the following parameter-passing methods, what are all of the values of the variables value and list after each of the three calls to swap?
a. Passed by value
b. Passed by reference
c. Passed by value-result

Question 3. 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 after execution?
a. Passed by value
b. Passed by reference
c. Passed by value-result

Question 4. C# supports out-mode parameters, but neither Java nor C++ does. Explain the difference.

Question 5 Write a program in a language that you know to determine me ratio in the time required to pass a large array by reference and the time required to pass the same array by value. Make the array as large as possible on the machine and implementation you use. Pass the array as many times as necessary to get reasonably accurate timings of the passing operations.

Question 6. Show the stack with all activation record instances, including static and dynamic chains, when execution reaches position 1 in the following skeletal program. Assume bigsub is at level 1.

function bigsub() (
function a() { function ho)
function b() {

....<---------------1
}//end of b

function c() {

...

b();

} //end of c

....

c ();

end of a;

...

a();

end of bigsub

Question 7: The static-chain method could be expanded slightly by using two static links in each activation record instance where the second points to the static grandparent activation record instance. How would this approach affect the time required for subprogram linkage and nonlocal references?

Question 8. If a compiler uses the static chain approach to implementing blocks, which of the entries in the activation records for subprograms are needed in the activation records for blocks?

Question 9: Suppose someone designed a stack abstract data type in which the function top returned an access path (or pointer) rather than returning a copy of the top element. This is not a true data abstraction. Why? Give an example that illustrates the problem.

Question 10. Why are destructors rarely used in Java but essential in C++?

Question 11. What are the advantages and disadvantages of the ability to change objects in Ruby?

Question 12. Design a queue abstract data type for float elements in a language that you know, including operations for enqueue, dequeue, and emptyThe dequeue operation removes the element and returns its value.

Question 13. Modify the Java class for the abstract stack type shown in Section 11.4.4 to use a linked list representation and test it with the same code that appears in this chapter.

Question 14. Compare the multiple inheritance of C++ with that provided by interfaces in Java.

Question 15. Explain the advantages and disadvantages of having all values in a language be objects.

Question 16 )Write a program in C++ that calls both a dynamically bound method and -ala statically bound method a large number of times, timing the calls to both of the two. Compare the timing results and compute the difference of the time required by the two. Explain the results.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: What are arguments for and against a user program building
Reference No:- TGS01683194

Expected delivery within 24 Hours