Selamat Datang di Blog Saya. Blog ini dibuat untuk memenuhi tugas dari dosen saya tercinta Bapak Ir.Tri Djoko Wahjono , M.Sc . Kiranya Blog ini bisa menambah pengetahuan bagi kalian. Isi blog ini mengenai konsep bahasa pemrogramman. Dan blog ini di sponsori oleh Bina Nusantara Alam Sutera.
Posted by : Unknown Minggu, 14 Desember 2014

Name : Romy Hermawan
NIM    : 1801378902
Class : LD001
Lecturer: Ir. Tri Djoko Wahjono,M.Sc

REVIEW QUESTION:

6. What associativity rules are used by APL?
Answer :
all operators have equal precedence and all operators associate right to left.

 7. What is the difference between the way operators are implemented in 
C++ and Ruby?
Answer:
all of the arithmetic, relational, and assignment operators, as well as array indexing, shifts, and bitwise logic operators, are
implemented as methods in Ruby.

 8. Define functional side effect.
Answer:
Functional side effect occurs when the function changes either one of its parameters or a global variable.

 9. What is a coercion?
Answer:
A coercion is an implicit type conversion.

 10. What is a conditional expression?
Answer:
a conditional expression is a statement that contains if-then-else to perform a conditional expression assignment.

PROBLEM SET:


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?
Answer:
Yes C should, because it will ease 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 operation, instead it is an increment or decrement which is usually used in repetition.

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

Answer:
It wouldn’t be commutative when it deals with the negative integers. Recall that we can consider subtraction as addition in which one of two operator is a negative integer.

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

It is not associative when it includes the other operator with higher precedence like the multiplication and division.



9. Assume the following rules of associativity and precedence for expressions:
Untitled
Show the order of evaluation of the following expressions by parenthesizing
all subexpressions and placing a superscript on the right parenthesis
to indicate order. For example, for the expression

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

Answer:


(a) ( ( ( a * b )1 – 1 )2 + c )3

(b) ( ( ( a * ( b – 1 )1 )2 / c )3 mod d )4

(c) ( ( ( a – b )1 / c )2 & ( ( ( d * e )3 / a )4 – 3 )5 )6

(d) ( ( ( – a )1 or ( c = d )2 )3 and e )4

(e) ( ( a > b )1 xor ( c or ( d <= 17 )2 )3 )4

(f) ( – (a + b)1 )2



10. Show the order evaluation of the expression of problem 9, assuming that there are no precedence rules and all operators associate right to left.
Answer:
(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

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Popular Post

Diberdayakan oleh Blogger.

- Copyright © Binusian IT 2018(Concept of Programming Language) -Metrominimalist- Powered by Blogger - Designed by Romy Hermawan -