Pada post
Review Questions
1. What associativity rules are used by APL?
APL used right to left associativity rule s for all operators.
APL used right to left associativity rul
2. What is the difference between the way operators are implemented in C++ and Ruby?
All of the arithmetic, relational, and assignment operators, as well as array indexing, shifts, and bitwise logic operators, are
implemented as methods in Ruby while C++ doesn’t.
All of the arithmetic, relational, and assignment operators, as well as array indexing, shifts, and bitwise logic operators, are
3. Define functional side effect.
4. What is a coercion ?
Coercion is an implicit type of conversion only if they are widening (from a “smaller” type to a “larger” type). Soint to float coercions are done across the assignment operator, but float to int coercions are not.
Coercion is an implicit type of conversion only if they are widening (from a “smaller” type to a “larger” type). So
5. What is a conditional expression?
Problem Sets
operation , instead it is an increment or decrement which is usually used in repetition.
associative when it includes the other operator with higher precedence like the multiplication and division.
6. Should C’s single-operand assignment forms (for example, ++count) be included in other languages (that do not already have them)? Why or why not?
Yes because it will make easier the increment or even decrement while we use in looping rather than manually by the assigning, and also by using that we can easily know that it is not
7. Describe a situation in which the add operator in a programming language would not be commutative.
It wouldn’t be commutative when it deals with the negative integers. For example -9 – 6 equals to -15
8. Describe a situation in which the add operator in aprogramming lan - guage would not be associative.
It is not It wouldn’t be commutative when it deals with the negative integers. For example -9 – 6 equals to -15
8. Describe a situation in which the add operator in a
9. Assume the following rules of associativity and precedence for expressions:
a + b * c + d
the order of evaluation would be represented as
((a + (b * c)1)2 + d)3
a. a * b - 1 + c
b. a * (b - 1) / c mod d
c. (a - b) / c & (d * e / a - 3)
d. -a or c = d and e
e. a > b xor c or d <= 17
f. -a + b
(a) ( ( ( a * b ) 1 – 1 )2 + c ) 3
(b)
(c)
(d)
(e)
(f)
10. Show the order of evaluation of the expressions of Problem 9, assuming that there are no precedence rules and all operators associate right to left.
(a) ( a * ( b – ( 1 + c )1 )2 )3
(b)( a * ( ( b – 1 )2 / ( c mod d ) 1 )3 )4
(c)( ( a – b ) 5 / ( c & ( d * ( e / ( a – 3 )1 )2 )3 )4 )6
(d)( – ( a or ( c = ( d and e ) 1 )2 )3 )4
(e)( a > ( xor ( c or ( d <= 17 )1 )2 )3 )4
(f) ( – ( a + b )1 )2
(a) ( a * ( b – ( 1 + c )1 )2 )3
(b)
(c)
(d)
(e)
(f) ( – ( a + b )1 )2
No comments:
Post a Comment