Archives for category: Uncategorized

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.

Review Question

1. What is a descriptor ?

2. What are the advantages and disadvantages of decimal data type ?

4.  Describe the three string length option.

5. Describe ordinal, enumeration, subrange types.

8. What are the design issues for arrays ?

32.  What are the design issues for unions?

33. Are the unions of ADA always type checked?

45. Define Strongly typed

49. Why are C and C++ not strongly typed?

50. What is name type equivalence?

51. What is structure type equivalence?

Problem Set

2. How are negative Integers stored in memory?

7.  compare pointer and reference types in C++.

9. C provides two derived data type both for name and structure type equivalence: struct and union. Make a study on when to use struct type variables and union type variables.

19. Any type defined with typedef is type equivalent to its parent type. How does the use of typedef differ in C and C++?

1. Descriptor is a collection of the attributes of a variable

2. Row major order is the element of the array that have their first subscript the lower bound value of that subscript are stored first, followed by the elements of the second value of the first subscript. Column major order, the elements of an array that have as their last subscript the lower bound value of that subscript are stored first, followed by the elements of the second value of the last subscript.

4. First, the length can be static and set when the string is created. Such string is called static length string. Second is to allow strings to have varying length up to a declared and fixed maximum set by variable’s definition as exemplified by the strings in C and the C-style strings of C++. This are called limited dynamic length strings. The third option is to allow strings to have varying length with no maximum.

5. ordinal type is one in which the range of possible values can be easily associated with the set of positive integers.

Enumeration is one In which all of the possible values, which are named constant, are provided a way of defining and grouping collections in the definition.

Subrange type is contiguous subsequence of an ordinal type.

8. design issue for arrays

-What types are legal for subscripts?

-Are subscripting expressions in element references range checked?

-when are subscript range bound?

-What dose array allocation take place ?

-Are ragged or rectangular multidimensioned array allowed, or both?

32.

-Should type checking be required? Note that any such type checking must be dynamic.

-should unions be embedded?

33. no. The user can tell the system when the type checking can be static. Such a restricted variable is called constrained variant variables.

45. strongly typed if type errors are always detected.

49. C and C++ are not strongly typed languages because both include union types, which are not type checked.

50. Name type equivalence means that two variables have equivalent types if they are defined wither in the same declaration or in declaration that use the same type name.

51. Structure type equivalence means that two variables have equivalent types if their types have identical structure.

Problem set

2. The value of integer, will negative if the left-most value is 1.

7. pointer in C++ can be used in the same ways as addresses are used in assembly languages. Meanwhile References type in C++ is a constant pointer that is always implicitly dereferenced.

9.  Struct is used to some member with different data type.Union is used to specify union structured. Union you are only supposed to use one of the elements.

19. Typedef in C, we have to use keyword “typedef”. But in C+ +, we don’t need to do that.

1. Descriptor is a collection of the attributes of a variable

2. Row major order is the element of the array that have their first subscript the lower bound value of that subscript are stored first, followed by the elements of the second value of the first subscript. Column major order, the elements of an array that have as their last subscript the lower bound value of that subscript are stored first, followed by the elements of the second value of the last subscript.

4. First, the length can be static and set when the string is created. Such string is called static length string. Second is to allow strings to have varying length up to a declared and fixed maximum set by variable’s definition as exemplified by the strings in C and the C-style strings of C++. This are called limited dynamic length strings. The third option is to allow strings to have varying length with no maximum.

5. ordinal type is one in which the range of possible values can be easily associated with the set of positive integers.

Enumeration is one In which all of the possible values, which are named constant, are provided a way of defining and grouping collections in the definition.

Subrange type is contiguous subsequence of an ordinal type.

 

8. design issue for arrays

-What types are legal for subscripts?

-Are subscripting expressions in element references range checked?

-when are subscript range bound?

-What dose array allocation take place ?

-Are ragged or rectangular multidimensioned array allowed, or both?

32.

-Should type checking be required? Note that any such type checking must be dynamic.

-should unions be embedded?

33. no. The user can tell the system when the type checking can be static. Such a restricted variable is called constrained variant variables.

45. strongly typed if type errors are always detected.

49. C and C++ are not strongly typed languages because both include union types, which are not type checked.

50. Name type equivalence means that two variables have equivalent types if they are defined wither in the same declaration or in declaration that use the same type name.

51. Structure type equivalence means that two variables have equivalent types if their types have identical structure.

Problem set

2. The value of integer, will negative if the left-most value is 1.

7. pointer in C++ can be used in the same ways as addresses are used in assembly languages. Meanwhile References type in C++ is a constant pointer that is always implicitly dereferenced.

9.  Struct is used to some member with different data type.Union is used to specify union structured. Union you are only supposed to use one of the elements.

19. Typedef in C, we have to use keyword “typedef”. But in C+ +, we don’t need to do that.

Preview question

1. The case sensitive and the special words of the language.

2. the most potential danger of case-sensitive names is when we write a variable in capital letter unintentionally, and then we use non-capital word to call the variable.

4. Alias is the variable that have same address, where the other variable can be used to access same memory allocation

7. Binding time is the place when binding was occurred. While binding is an association between an attribute and an entity.

18.  Blocks is the section that allows to have its own local variables whose scope is minimized.

Problem Set

1.

_student is valid because C language allows variable begins with underscore(_)

Int is not valid, because int is a data type in C

Student is Valid, because it begins with a letter

123student is not valid, because it’s prohibited to  begin a variable with a number in C language

Student123 is valid, because C language allows use number after a letter or an underscore

2. l-value is an expression that point to memory

Example

Int m[2]={1,2};

Printf(“%d”, m+1);

5. static type binding required when we have to bind a variable to a type based on the syntactic form of the variable ‘s name. Dynamic type binding required when we don’t need to declare it with specification.

1.  Syntax is the study of the rules that govern the ways words combine to form phrases, clauses, and sentences

2.  Language description for the programmer or who use the intended language

3.  language generator is a device that can be used to generate the sentences of a language. We can think the generator as having a button that produces a sentence of the language every time it is pushed.

4. suppose we have a language L that have $ as an alphabet. To define L formally, we have to construct a mechanism R (called a recognize device), capable of reading string of characters from alphabet $.

8. Static semantic is a formal form of the language program. Dynamic semantics is a perspective on natural language semantics that emphasizes the growth of information in time

10. The synthesized attributes are the result of the attribute evaluation rules, and may also use the values of the inherited attributes. The inherited attributes are passed down from parent nodes.

23.  it based on mathematics logic

24. recursive function theory

 

 

Problem Set

1. Syntax error is when we use a wrong typing

Example : for(a==0;a<9;a++);

Semantic error is logical error

Example : for(a=9;a>0;a++);

5.

== : Equal to

!= : Not equal to

< : Less than

> : Greater than

>= : Greater or equal to

<= : Less or equal to

6.

a. Image

b.Image

c.Image

11.

a. bbaabb

c.bbaaaabb

12.

e. accdc

18. fully attributes parse is when all of attributes of the parse tree have been calculated

 

Lecturer : Tri Djoko Wahjono, Ir. M.Sc

Preview question

1.     Plankalkul designed in 1943, and it is published at 1972

3.     Plankalkül is a computer language designed for engineering purposes by Konrad Zuse between 1943 and 1945. It was the first high-level non-von Neumann programming language to be designed for a computer. And it is a calculus program.

8.   John Mauchly developed the short code. Because Short code was not translated to machine code. It was implemented with a pure interpreter. Short code interpretation was approximately 50 times slower than machine code.

10. Independent compilation is the significant features which is added in to Fortran II

11.  Logical loop control statement

13. Fortran 77 was the first Fortran that has a string handling

18.  ACM and GAMM

22.  FLOW-MATIC was the mother language of COBOL

28. APL and SNOBOL

32.  The design criterion was used in ALGOL 68 is orthogonality

33. ALGOL-W

39.  Tasks

47. Thompson who is a language designer who work on both C and go

52.  Params

57. Java support data type such as int, byte, float, double, boolean, and char.

61. Lua is purely interpreted

66. The output of  XSLT can be HTML or plain text.

Problem Set

1.    Explicit Type declaration for variable, a logical if construct, and the capability of passing subprograms as parameters to other subprogram

6.   The most frequently error in C program is in the looping and the if statement. because, we can still run the program with the error if.

8. Speedcoding did not become the widely used language, because it isn’t provided any feature like in the others. it is good in calculation, but not in Structure data

9.    Because at the time, the scientists and engineers  always use I, J, K, so forth for writing the variable in to their formula.

10. – ALGOL 58

-ALGOL 60 design process

-ALGOL 60 Overview

13. Because C more complete and easier than Fortran. and Fortran doesn’t have any important feature like in C.

14. Typeless language is less readable. because it’s too hard to understand a program which made in typeless.

15.  Yes, LISP.

Lecturer : Mr. Tri Djoko Wahjono, Ir. M.Sc

 

Review question

1. because with mastering many of programming languages, we have more experience with it, and we can choose one of the languages that we have learned, which is appropriate with the program. and we have a big chance to have a job in a company

3. Fortran

4. COBOL

5. LISP

15. Aliasing refers to an effect that causes different signals to become indistinguishable

17. because, if we make a program that less readability, the other programmer get difficult to understand it. but, if we make a readability program, we can understand it, and make a new code

20. Imperative languages

22. encapsulation, inheritance, polymorphism

23. SmallTalk

29. the language are compromise between compilers and pure interpreters. they translate high-level language program to an intermediate language designed to allow easy interpretation.

Problem Set

1. i think not. because to solve a problem in a particular algorithm, we prefer use our logic than skill in programming language. because programming language without logic is useless. all of problem in algorithm require a good logic.

2. Ada lovelace

3. the disadvantage is sometimes we use an appropriate syntax. like we use Java syntax in C program for instance.

6. I think reliability is the most important thing. because it is included writabilty &  readability.

12. I think, we can’t call any programming language complete, because each program language has its disadvantages and advantages. and programming language is a relative to person. may be someone feels good in “A” programming, and not in “B” Programming. but, may another person feel “B” is more comfortable to use.

16. yes, it does. because during execution, it compiles intermediate language methods into machine code when they are called.