Monday 8 April 2013

Chapter 6



Concept of Programming Languages by Robert W. Sebesta Answer

Review Questions

1. What is a descriptor ?
Collection of the attributes of a variable


4. Describe the three string length options.
The length can be static and set when the string is created, allow strings to have varying length up to a declared and fixed maximum set by the variable’s definition. And allow strings to have varying length with no maximum.

5. Define ordinal, enumeration, and subrange types.

-Ordinal type is one in which the range of possible values can be easily associated with the set of positive integers.
-Enumeration type is one in which all of the possible values, which are named constants, are provided, or enumerated, in the definition.
-Subrange type is contiguous subsequence of an ordinal type.

6. What are the advantages of user-defined enumeration types ?
Improved writability and readibility, No arithmetic operations are legal on enum types and no enumeration types can be assigned values outside its defined range.

10. What happens when an nonexistent element of an array is referenced in Perl ?
No error will be reported

7. Who developed the Speedcoding system for the IBM 701 ?
The language was developed by John Backus in 1953 for the IBM.

10. What was the most significant feature added to Fortran 1 to get Fortran II ?
It added independent compilation of subroutines. Without it, any change in a program required the entire program to be recompiled.

11. How does JavaScript support sparse arrays ?
The value of subscripts need not to be contiguous

12. What languages support negative subscripts ?
Ruby and Lua


13. What languages support array slices with stepsizes ?
Python,Perl and Ruby

14. What array initialization feature is available in Ada that is not available in other common imperative languages ?
Listing arrays in order in which they are to be stored or direcly assigning them to an index position using the => operator

15. What is an aggregate constant ?
Nonscalar constant which value never change or are not changed during execution of the program

16. What array operations are provided specifically for single-dimensioned arrays in Ada ?
Ada allows array assignments, including those where the right side is an aggregate value rather than an array name. Ada also provides catenation, which is defined between two single-dimensioned arrays and between a single-dimensioned array and a scalar. Nearly all types in Ada have built-in relational operators for equality and inequality.



17. Define row major order and column major order.
Row major order is where elements of the array that have as their first subscript the lower bound value of the subscript are stored first.
Column major order has elements of an array that have as their last subscript the lower bound value of that subscript are stored first.


18. What is an access function for an array ?
For multidimensional array : the mapping of its base address and a set of index values to the address in memory of the element specified by index values.

For two-dimensional array : the address of an element is the base address of the structure plus the element size times the number of elements that precede it in the structure.


21. What is the purpose of level numbers in COBOL records ?

It represents relation between groupd and elementary items in COBOL

44. Define type error.
Type error is the application of an operator to an operand of an inappropriate type.

45. Define strongly typed.
Characteristic of programming language where the variable declaration is matter.

Problem Set


2. How are negative integers stored in memory ?

It uses most-significant-bit (the leftmost number). The “sign bit”. If it is 1, the number is negative. Vice versa.


3. The collection of values that can be represented by a floating-point type is defined in terms of precision and range. What are precision and range ? Show the IEEE floating-point standard 754 format for single- and double-precision representation.

Precision is accuracy of the fractional part of a value. Range is a combination of the range of fractions and, more important, the range of exponents.
Representation of IEEE floating-point standard 754 format for single- and double- precision.


6. Compare the use of Boolean data types in C++ and Java. Give emphasis on their use in conditional statements and conditional loops.

The use of boolean in C++ and Java is almost the same. Boolean is a variable which has only 2 values : true and false. The only difference would be the primitive in C++ is bool while Java uses Boolean. On their use of conditional statements, they determine whether a loop or conditional statement is executed. The difference is that Boolean in Java does not accept integers as true / false value. They only accept the value either “true” or “false”. While in C++, it is possible to assign 1 as the value of a boolean which means true and 0 as false.

21. In what way is dynamic type checking better than static type checking ?

Dynamic type checking allows the programmer to be more flexible. Because the dynamic checking is happening on compile time, not run time. And earlier correction is less costly.
Than later correction in case of static type checking usage, which runs on runtime of the application.

0 comments:

Post a Comment