Review Question

2. What is a ternary operator ?

3.  What is a prefix operator ?

6. What is associativity rules are used by APL ?

9. What is a coercion?

18. What is short-circuit evaluation?

24. What two languages include multiple assignment ?

Problem Set

4. Would it be a good idea to eliminate all operator precedence rules and require parentheses to show the desired precedence in expression? Why or why not?

7. Describe a situation in which the add operator in a programming language would not be commutative.

8.  Describe a situation in which the add operator in a programming language would not be associative.

15. Explain Why it is difficult to eliminate all functional side effects side in C.

Answer

2. that is a conditional syntax which has 3 operands

3. prefix operator that precede their operands.

6. Functional side effect occurs when the function changed either one of its parameters or a global variable.

9. Coercion is A type of conversion which an operation that takes a value of one type and returns a value of another type such that the two values are somehow equivalent

18. A short-circuit evaluation is one in which the result is determined without evaluating all of the operands and/or operators.

24. Perl and ruby are including language that provide a multiple assignment

 

Problem set

4. I think that is a good idea. Because people who still confuse about the precedence rule can understand which part will begin first.

7.

Int y = 9;

++y + y =20. But if y+(++y) = 19;

8. there are two situations. First, if two large numbers are being added together before a third large but a negative value, one may or may not get overflow depending on the order of the additions.

Second is when a functions that has a side effect is involved in the addition. If the function modifies one of the value in the expression.

15. It’s difficult because all subprograms return one value. To eliminate the side effects of two-way parameters and still provide subprograms that return more than one value, the values would need to be placed in struct and the struct returned.

Advertisements