More Standard Pascal Questions  KEY

note that there are only 19 questions

 

 

1. What are the delimiters used to surround an array index?

[ ]

 

 

2. Where do Pascal array bounds start?

any integer range can be used (i.e.  [-5…4] or [68..79]

 

 

3.  Why must all variables be declared in Pascal?

because Pascal is a strongly typed language and the compiler needs to check the assignments against types

 

 

4.  Where are subprograms placed physically in a standard Pascal program?

after the main program declarations and before the word begin

 

 

5.  Is Pascal case sensitive?

no

 

 

6.  Does Pascal allow mixed mode arithmetic? 

yes

 

 

7.  Given an example of an anonymous array declaration in standard Pascal.

var myarray : array[1..3] of integer;

anonymous array variables  have names but not types

 

 

8.  In what circumstances is an anonymous array declaration not allowed?

as a parameter

Pascal parameters require that their type be indicated in the formal header of the subprogram

 

 

9.  Suppose you declare a 10 element array of integers, assign values to 8 of the elements and print out all 10 elements.  What happens in your version of Pascal?  (what version do you have?)

most of your compilers initialized program variables to 0 and thus printed 0

 

 

10.  Suppose you declare a 5 element array of integer and attempt to print out the 6th through 10th   elements.  What happens in your version of Pascal?  (what version do you have?)

depended on the compiler

  some caused compiler errors

  some showed zeroes

 others showed miscellaneous values already stored  in the

      memory locations.

 

 

 

11.  Does Pascal allow you to dynamically allocate storage?   If so, how is it done?

yes - using the function call new  to obtain a new address in which to store object

 

 

12.  What is the Pascal symbol for the relational operator 'not equal'?

<>

 

 

13. In Pascal, which has higher precedence and or or? or do they have equal precedence?

and

 

 

14.  What are the Boolean values in Pascal?

false  and true

 

 

15.  What Pascal type is illustrated by the type Boolean?

enumerated

 

 

16.  Can you read or write values of an enumerated type in Pascal?

answer should be no

some version may allow it

 

 

17.                Is it legal to have the same value as an element of an enumerated type in Pascal?  (i.e. can you have the following two type declarations in the same program?

  type trafficLight = (red, green, yellow);  

 type crayon = (red, orange, blue);

If not, why not?

no

 

 

 

 

 

compiler sees it as a redeclaration of any already declared variable

 

 

18.  How long can an identifier be in your version of Pascal? What is your version?

standard Pascal says 8

your compilers varied a lot

 

 

20.  Pascal has two methods of parameter passing.  Which is the default?

pass by value (i.e. copy in)