Minggu, 31 Maret 2013

Concepts of Programming Languages - Chapter 3


Review Questions
1.       Syntax is the form of programming language expressions, statements, and program units. Semantics is the meaning of those expressions, statements, and program units.
7.    Brackets, braces, multiple-choice options.
9.    State the static semantic rules of the language.
12.  To provide complete descriptions of the syntax and static semantics of programming languages.
14.  The individual steps in the execution of machine language and the resulting changes to the state of the machine are too small and too numerous, and the storage of a real computer is too large and complex.
16.  Syntactic domain is the domain that syntactic structures are mapped, semantic domain is the range of the map.
18.  Denotational semantics
27.  Loop invariant is the corresponding step in the axiomatic semantics of a while loop is finding an assertion. Example: I is the loop variant
P=> I
{I and B} S{I}
(I and (not B)) => Q
28.  To treat the process of producing a weakest precondition as a function, because it takes a predicate, or assertion, as a parameter and returns another predicate.
29. Total correctness is if loop termination can be shown, partial correctness if the other conditions can be met but termination isn’t guaranteed.

Problem Set
1.       A syntax error is an error in the typing of the code or statement, and a semantic error is a logic error.
scanf(%d,&a); >> syntax error because in %d it should be start and end with “
char asd[50]; char asd2[25]; printf(“%d”,asd); >> logic error because it is a string data type but it print out with integer data type

3.
<assign> <id> = <expr>
<id> A | B | C
<expr> <expr> + <term>
             |   <term>
<term> <term> * <factor>
              |   <factor>
<factor> ( <expr> )
                |   <id>


13. S->ab | aSb
      b->bb
15.
<program> -> begin <stmt_list> end
<stmt_list> -> <stmt>
| <stmt> ; <stmt_list>
<stmt> -> <var> = <expression>
<var> -> A | B | C
<expression> -> <var> {(+|-) <var>}

16.
<expression> -> <var> {(+|-) <var>}
<assign> -> <id> = <expr>
<id> -> A | B | C
<expr> -> <expr> {(+|*) <expr>}
| <id>

18. Fully attributed parse tree is a condition of a parse tree when all the attribute values in it have been computed.

23.
a.
a = 2 * ( b – 1 ) – 1 { a > 0 }
a = 2b – 2 – 1 { a > 0 }
a = 2b – 3 { a > 0 }
2b – 3 > 0
2b > 3
b > 3/2

b.
b = ( c + 10 ) / 3 { b > 6 }
b = c / 3 + 10 / 3 { b > 6 }
c / 3 + 10 / 3 > 6
c + 10 > 18
c > 8

c.
a = a + 2 * b ? 1 { a > 1 }
a = a + 2b – 1 { a > 1 }
a + 2b – 1 > 1
2b > 2 – a
b > 1 – a/2

d.
x = 2 * y + x ? 1 { x > 11 }
x = 2y + x – 1 { x > 11 }
2y + x – 1 > 11
2y > 12 – x
y > 6 – x/2

24.
a.
a = 2*b+1;
b = a – 3
{ b < 0 }
a – 3 < 0
a < 3
a = 2 * b + 1 { a < 3 }
2b + 1 < 3
2b < 2
b < 1

b.
a = 3*( 2*b+a );
b = 2*a – 1
{ b > 5 }
2a – 1 > 5
2a > 6
a > 3
a = 3 * ( 2 * b + a) { a > 3 }
3 * ( 2b + a ) > 3
2b + a > 1
2b > 1 – a
B > ( 1 – a ) / 2


Minggu, 10 Maret 2013

Concepts of Programming Languages - Chapter 2


Review Question

7. John Backus
8. John Mauchly
10. The Independent compilation of subroutines
12. Fortran IV
13. Fortran 77
17. Scheme
23. 1959
27. It was easy for beginners to learn, especially those who were not science oriented, and its smaller dialects can be implemented on computers with very small memories.
30. Class construct
33. ALGOL-W
34. For, switch
37. Facts, rules
44. Smalltalk
45. Traditional Object-oriented programming
52. Params
65. XML data document and XSLT document
68. Servlet

Problem Set

1. Explicit type declarations for variables, logical if construct, capability of passing subprograms as parameters to other subprograms

2. Short code was one of the successful stored program electronic computers, transferred to UNIVAC I computer, consist of coded versions of mathematical expressions that were to be evaluated. Short code wasn’t translated to machine code, it was implemented with a pure interpreter. It simplified the programming process, but at the expense of execution time. Because of that hand calculator is 50 times faster than short code

9. The purpose is to make easier for declaring a variable

10. Introducing concept of block structure, pass by value and pass by name to subprograms were allowed, procedures were allowed to be recursive, stack-dynamic arrays were allowed

13. C is well suited for a wide variety of applications

15. Yes, there are like VB, SQL

24. Because nowadays network users are increase day by day, because of that reason people want to make scripting languages for helping web programmer to handle that case1

25. Java servlet is server-side Java program modules that process and answer client requests and implement the servlet interface

Minggu, 03 Maret 2013

Blog's purpose post entry

Hi , I'm Felix Kantio Hardhy Saputra (1601234751) from class 02PCT.

I make this blog especially for submit my assignment to Mr. Tri Djoko Wahjono for Concept of Programming Languages 02PCT class.

Concepts of Programming Languages - Chapter 1


Review Questions

1.       Because it can increase our capacity to use different constructs in writing programs, enables us to choose languages for projects more intelligently, and makes learning new languages easier.

2.       It makes us better in understanding of the significance of implementation, in use of languages that are already known.

3.       Fortran

4.       COBOL

5.       LISP

6.       C

7.       Disadvantage of having too many features are make the users confused about what features will they used for solving problems, and  not all of the features will be used by the user

8.       Operator overloading means that a single operator symbol has more than one meaning, it can lead to reduced readability if users are allowed to create their own overloading and don’t do it sensibly, and it would make the program more confusing for both the author and the program’s reader.

9.       In case structured data type (record and array), record can be returned from function but arrays can’t. Parameters are passed by value, unless they are arrays, in case they are, in effect, passed by reference.

10.   ALGOL 68

Problem Set

1.       Yes, because when we want to make an algorithmic step for a program at least we can tell what kind of function will be used by us to make the program, so we can create and test the program as soon as we can after we have done with the algorithm.

2.       Ada Lovelace

3.       Disadvantages of multiple programming languages are sometime we could forget or confused in using the function in some type of languages, lack of time to study all of languages

4.       Scientific applications support for scientist and for complicated calculation, but can be used in business too sometimes, but languages for business applications support for economical purpose and can’t be used by scientist for calculating formulas and kinds of complicated calculation.

5.       Languages for artificial intelligence are developed in type of software and mostly used for programming an artificial things, language for web software are designed for make web content, HTML type.

6.       Reliability, because when a program is said to be reliable it include overall criteria of a good program such as simplicity, orthogonality, readability, writability, etc. And it has a lower cost