Misc. Questions from previous exams of CPSC 110, this may or may not help you.

These are mostly from the SECOND and THIRD exams (though subject material covered varies slightly from semester to semester so some questions may not have yet been covered in ‘your’ class). Some questions may be repeated. Few (if any) answers to these questions will be provided. The actual gain in this is if you look the answers up or type the short programs in and discover the answers yourself.

In no way are these questions guaranteed to help you (but it is extremely unlikely they would hurt you). If you print this it will use about 41 pages.

 

 

In Pascal, procedure declarations are placed:

  1. after the main body of the program
  2. after the variable declarations and before the main body
  3. within the main body
  4. before the (global) variable declarations
  5. anywhere you like

 

Which of the following is an illegal assignment statement (assume all variables properly declared)?

  1. x := x + y;
  2. pRoWd := good + job;
  3. avg := 9 + 4 + 8 / 4;
  4. 5 := b;
  5. times := 1 + 4 + 22;

 

Today in the U.S. the pseudocode of an algorithm is written in

  1. low level language
  2. mix of English and high level language
  3. mix of English and low level language
  4. ancient Greek or Egyptian
  5. all of the above

 

The first general purpose, purely electronic digital computer was:

  1. TI – 83
  2. Colossus
  3. ENIAC
  4. Mark I
  5. Atari 2600

 

What “generation” of computer are we currently producing?

  1. second
  2. third
  3. fourth
  4. fifth
  5. sixth

 

How many bits are in a byte?

  1. 1
  2. 2
  3. 4
  4. 8
  5. 16

 

Which of the following is NOT a key hardware component?

  1. operating system
  2. CPU
  3. main memory
  4. secondary memory devices
  5. input / output devices

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

every time you compile your program (T/F).

 

 

 

·         The following Pascal program section is valid

Program Interest;

Var

                Principal, Rate, Time: Integer;

                Sum, Principal: Real;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

If a unit named Bob is in a file UNIT1.PAS and you compile it to disk, the compiled version

of the unit will be in a file named:

 

  1. BOB.TPU
  2. BOB.PAS
  3. BOB.TXT
  4. UNIT1.TPU
  5. UNIT1.TXT

 

 

 

 

Given the below 4 types of declarations:

1)       Constant Declarations

2)       Variable Declarations

3)       Type Declarations

4)       Procedure and Function Declarations

 

What is the order the book says they should be done in a program?

 

  1. 1, 2, 3, 4
  2. 1, 3, 2, 4
  3. 4, 2, 1, 3
  4. 4, 3, 2, 1
  5. 3, 4, 2, 1

 

The next 3 questions assume the following declarations:

Type

   Aggie = array [1..100] of integer;

Var

   A, B, C : Aggie;

   i, j, sum : integer;

 

What does the following piece of code do given the above declarations and assuming it

is embedded in a working program ?

 

For i:= 1 to 100 do

   A[i] := B[100 + i + 1];

 

  1. Copies the array B to A
  2. Copies the array A to B
  3. Stores in B, the reverse array of B.
  4. Stores in A, the reverse array of B.
  5. None of the above.

 

Given the above declarations and assuming it is embedded in a working program, what does the following piece of code do ?

 

for i:=1 to 100 do

begin

   sum := A[i];

   A[i] := B[i];

   B[i] := sum;

end;

 

  1. Reverses the contents of both A and B.
  2. Swaps the contents of A and B (i.e. When the loop completes, the content of A = what the content of B was before the loop and the content of B is what the content of A was before the loop)
  3. Finds the sum of the contents of A and B.
  4. Copies the contents of A into B, leaving A unchanged.
  5. None of the above.

 

If we want to add the arrays A and B componentwise and store the result in the array C

(i.e. C[i] := A[i] + B[i];) how many cells from A, B and C do we have to access?

 

  1. 100
  2. 200
  3. 300
  4. 600
  5. none of the above.

 

 

 

 

 

 

In the book ADT stands for which of the following:

 

  1. Aggies Dominate Texas
  2. Abstract Down Time
  3. Any Darn Thing
  4. Abstract Data Type
  5. AqueDuct Turnpike

 

Which of the following is an illegal Pascal expression (assume all variables are declared correctly)

  1. 2 * 5 * n – sqrt(20) / 2;
  2. x / (( 1 – y / 100) / z );
  3. p * q / 100 – r;
  4. amount * ( 1 + rate / 100);
  5. all the above are legal

 

In the following program segment (assume no syntax errors and embedded in a working program)

VAR

        x, y : integer;

BEGIN

        x := 3;

        y := 5;

        if 2 > x then

             y := 1

        else

             x := 5;

        if 4 < x then

             y := 2;

END.

 

What is the final value of y ?

  1. 1
  2. 5
  3. 2
  4. non-determinate; y may not be assigned a value
  5. none of the above

 

What does the operator <> mean in Pascal ?

  1. greater than
  2. equal to
  3. not equal to
  4. less than
  5. none of the above

 

What does the operator != mean in Pascal ?

  1. greater than
  2. equal to
  3. not equal to
  4. less than
  5. none of the above

 

Which of the following is NOT a valid Pascal function ?

  1. trunc(3.43);
  2. abs(-36);
  3. sqrt(35);
  4. square(3);
  5. exp(3.3);

 

Which of the following is an illegal actual value parameter of type integer? (Assume the variable n is of type integer).

  1. 34 / 3
  2. n + 1
  3. 26
  4. n
  5. All the above are legal

 

How many bytes is a Kilobyte ?

  1. 25
  2. 64
  3. 1024
  4. 100
  5. 1 million

 

Which of the following is the correct declaration for an array?

 

  1. A = array [1..10] of integer;
  2. A = array of [1..10] integer;
  3. A = integer[1..10] of array;
  4. A = integer array of [1..10];
  5. none of these

 

 

What is the output of the below program ?

 

program OutPut;

type

   ListArry = array[1..6] of char;

var

   i : integer;

   word : ListArry;

begin

   word[1] := ‘O’;

   word[3] := ‘L’;

   word[6] := ‘?’;

   word[5] := ‘H’;

   word[2] := ‘L’;

   word[4] := ‘E’;

   for  i := 6 downto 1 do

      write(word[i]);

end.

 

  1. HELLO?
  2. ?OLLEH
  3. HELLO
  4. ?HELLO
  5. There is no output

 

What is the output of the below program?

 

program AddStuff;

 

const

   MAX_SIZE = 5;

type

   score_array = array[1..MAX_SIZE] of integer;

var

   i, j, x : integer;

   scores : score_array;

 

begin

   for i:= 1 to MAX_SIZE do

      scores[i] := i;

 

   x := 0;

 

   for j := 1 to MAX_SIZE-2 do

      x := x + scores[j];

 

   writeln(x);

end.

 

  1. none of the below
  2. 3
  3. 6
  4. 10
  5. 15

 

 

Which of the following is NOT a “built in” string function/procedure in Turbo Pascal?

  1. length
  2. insert
  3. copy
  4. reverse
  5. pos

 

If the following statement is placed in a working program what is the value of p after the statement

is executed (assume p is type integer) ?

p := pos(‘be’, ‘dobedobedo’);

 

  1. 3
  2. 4
  3. 5
  4. 6
  5. 7

 

How many elements are in the following multi-dimensional array?

Var

   Test : array[‘A’..’D’,’a’..’d’] of integer;

  1. 2
  2. 4
  3. 8
  4. 16
  5. none of the above.

 

 

 

 

 

 

 

 

The next 3 questions refer to the below code:

program FoodBill;

type

   DeptName = (Meat, Deli, Produce, Grocery);

   AmountSpent = array[DeptName] of real;

   ExpenseArray = array[50] of AmountSpent;

var

   SpentOn : AmountSpent;

  CustomerExpense : ExpenseArray;

 

function Total(var B: AmountSpent) : real

var

   Dept: DeptName;

   Sum : real;

begin { Total }

   Sum := 0;

   for Dept := Meat to Grocery do

      Sum := Sum + B[Dept];

   Total := Sum;

end; { Total }

 

begin    { main }

   SpentOn[Meat] := 40.0;

   SpentOn[Deli] := 0.0;

   SpentOn[Produce] := 10.00;

   SpentOn[Grocery] := 45.00;

 

   writeln(Total(SpentOn):0:2);

end. { main }

 

What is the output of the above code.

 

  1. 95.00
  2. 100.00
  3. 40.00
  4. 45.00
  5. none of the above

 

In the above code the variable SpentOn is:

 

  1. an array of arrays
  2. a 1-dimensional array
  3. a 3-dimensional array
  4. a 4-dimensional array
  5. not an array

 

In the above code the variable CustomerExpense is:

  1. an array of arrays
  2. a 1-dimensional array
  3. a 3-dimensional array
  4. a 4-dimensional array
  5. not an array

 

 

A logical error is:

  1. a typing mistake
  2. a mistake in the underlying algorithm
  3. when logic circuits of the computer fail
  4. all of the above
  5. none of the above

 

Which of the following is not an input device?

  1. keyboard
  2. mouse
  3. scanner
  4. monitor (like the ones in your lab)
  5. all the above are input devices

 

In this class, a set of instructions that leads to a solution is called a(n) ?

  1. solution set
  2. procedure
  3. algorithm
  4. order set
  5. implementation

 

Which of the following does NOT make source code easier to read?

  1. comments
  2. indentation
  3. semicolons
  4. both A and B
  5. A, B and C

 

 

 

The next 3 questions  refer to the below code:

 

program MultiIndex;

type

   GradeArray = array[1..10, 1..20] of integer;

var

   MyArray : GradyArray;

   index, j : integer;

   q, r, s : integer;

 

begin   { main }

   for index := 1 to 10 do

   begin

      for j := 1 to 20 do

      begin

         if (index > j) then

            MyArray[index, j] := index - j

         else

            MyArray[index, j] := j – index;

      end;  { for j }

   end; { for index }

 

   q := MyArray[8, 8];

   r := MyArray[4, 2];

   s := MyArray[6, 9];

   { The questions will ask for the values of q, r, s at this point in the code }

   writeln(q, ' ', r, ' ', s);

end.

 

What is the value of q that is output?

  1. 0
  2. 1
  3. 2
  4. 3
  5. –2

 

What is the value of r that is output?

  1. 0
  2. 1
  3. 2
  4. 3
  5. –2

 

What is the value of s that is output?

  1. 0
  2. 1
  3. 2
  4. 3
  5. –2

 

The next 3 questions  refer to the below code:

 

program ArrayStuff;

type

   array_type : array[1..10] of integer;

var

   A, B : array_type;

   index, x, y, z : integer;

begin

   for index := 1 to 10 do

   begin

      A[index] := index + 1;

      B[index] := index;

   end; { for }

 

   B := A;

   B[3] := B[3] –2;

 

   x := B[3];

   y := A[3];

   z := B[4];

   { The questions will ask what the value of x, y, z are at this point in the code }

   writeln(x, y, z);

end.

 

What is the value of x that is output?

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

 

What is the value of y that is output?

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

 

What is the value of z that is output?

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

 

Assume the below code was embedded in a working program.

 

sum := 0;

for i:=1 to 5 do ;    { notice the semi-colon after the do is intentional }

   sum := sum + i;

writeln(sum);

 

What is the output of the above writeln?

 

  1. none of the below
  2. 0
  3. 3
  4. 6
  5. 15

 

Given the below declarations:

type

   Sample = record

                       F1 : integer;

                       F2 : char;

                    end;

var

   X1, X2 : Sample;

 

Assume the following code is embedded in a working Pascal program:

 

X1.F1 : = 5;

X1.F2 := ‘A’;

write(X1.F1, X1.F2, ‘ ---- ‘);

X2 := X1;

X2.F1 := 6;

X1.F1 := 4;

writeln(X2.F1, X2.F2);

 

What is the output?

 

  1. 6A ---- 5A
  2. 5A ---- 5A
  3. 5A ---- 6A
  4. 6A ---- 6A
  5. 5A ---- 4A

 

 

 

The next two questions refer to the below table:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

 

This table defines the two dimensional array A. Assume row 1 starts at the value 1

and row 2 starts at the value 6 and row 3 starts at the value 11. Assume column 1 starts

at 1, column 2 at 2, column 3 at 3, column 4 at 4, and column 5 at 5.

 

If we use ROW major order to index into A, then the value of A[2, 3] is:

 

  1. 12
  2. 9
  3. 8
  4. 6
  5. 3

 

If we use COLUMN major order to index into A, then the value A[2, 3] is:

 

  1. 12
  2. 9
  3. 8
  4. 6
  5. 14

 

 

Which of the following cannot be part of a procedure in Turbo Pascal 7.0:

a)       local variables

b)       local functions

c)       local named constants

d)       constant parameters

e)       they are all valid parts of a procedure

 

What is the output of the following code:

program Letter;

 

function NumToChar( N: integer): char;

begin

   NumToChar := 'Z';

   if (N = 1) then

      NumToChar := 'A';

   if (N = 3) then

      NumToChar := 'B';

end; { NumToChar }

 

begin {main program Letter }

   writeln(NumToChar(1), NumToChar(2), NumToChar(3));

end. { main program Letter }

 

a)       ZAB

b)       BAZ

c)       ABZ

d)       AZB

e)       none of the above

 

Which of the following subtasks is BEST implemented as a single function?

a)       Converting a given number of centimeters into feet and inches.

b)       Converting a given number of miles to an equivalent number of kilometers.

c)       Computing the net income and the tax due on an income tax return,

given the gross income and the adjustments to income.

d)       Computing the gas mileage and cost of a trip, given the miles traveled,

the number of gallons of gas consumed and the cost of gas per gallon.

e)       Displaying the output of a program to the screen

 

 

Which of the following expressions evaluates to false:

a)       true OR true

b)       not (true OR false)

c)       not (true AND false)

d)       true OR false

e)       true AND true

 

 

 

 

global variables inside a procedure (T/F).

 

Next 2 Questions  refer to the below program

program ShortCheck;

var

   kids, pieces : integer;

begin

   kids := 0;

   pieces := 100;

   if (kids <> 0) and (pieces div kids >= 2) then

      writeln('Each child may have two pieces.')

   else

      writeln('There are no kids.');

 

end.

 

Assuming the compiler IS using short-circuit evaluation the output is:

a)       Each child may have two pieces.

b)       There are no kids.

c)       The program does not run  – the compiler generates a syntax error.

d)       The program runs but it generates a runtime error.

e)       Both a) and b) are printed (on separate lines).

 

Assuming the compiler is NOT using short-circuit evaluation the output is:

a)    Each child may have two pieces.

b)       There are no kids.

c)       The program does not run  – the compiler generates a syntax error.

d)       The program runs but it generates a runtime error.

e)       Both a) and b) are printed (on separate lines).

 

Which of the following is NOT a boolean operator in Pascal?

a)       in

b)       and

c)       not

d)       or

e)       out

 

 

Next 2 questions refer to the below program:

program NoGoodCode;

var

   x, y, z : real;

begin

   x := 15.5;

   y := 11.12;

   z := 20.89;

   if (x > y) then   { this is line 8 }

        if (x > z) then

             writeln('x is the largest') 

        else if ( y > z) then

             writeln('y is the largest')   { this is line 12 }

   else if (y < z) then

      writeln('z is the largest')

   else

      writeln('y is biggest');

end.

 

What is the output of the program as it is written above?

a)       x is the largest

b)       y is the largest

c)       z is the largest

d)       y is the biggest

e)       There is no output

 

Assume there is a "begin" after line 8 and an "end" after line 12.

What is the output of the code if it is so modified?

a)    x is the largest

b)       y is the largest

c)       z is the largest

d)       y is the biggest

e)       There is no output

 

 

 

What is the output of the following code (when embedded in

correct programs with X declared to be of type integer)?

 

X := 10;

repeat

   X := X – 3;

until X <= 0;

writeln(X);

 

a)       0

b)       2

c)       –1

d)       –2

e)       –3

 

 

Next 2 Questions are based on the following program:

program ForKingdom;

var

   X, Y, Z : integer;

begin

       X:= -2;

Z := 1;

Y := -3;

for X := Y downto 0 do

      Z := X;

writeln(X);

end.

 

When the program completes what is the value of X ?

a)       1

b)       –1

c)       –2

d)       –3

e)       none of the above

 

When the program completes what is the value of Z ?

a)       0

b)       1

c)       –1

d)       –3

e)       none of the above

 

Which of the following is NOT a good method for terminating a loop in Pascal?

a)       Exit on sentinel value.

b)       Running out of input.

c)       Count controlled loops.

d)       Using a goto statement.

e)       Exit on flag condition.

 

 

 

What is the output of the below program?

program IfLoops;

var

   m, n, o : integer;

begin

   for m:=0 to 6 do

   begin

      if ( M < 4) then

          n := m + 3

      else

           if ( m > 5) then

                o := n + 2

           else if ( m = 6) then

                o := n + 1;

   end;

   writeln( o );

end.

 

a)       7

b)       8

c)       9

d)       10

e)       none of the above

 

Given the below code, what is(are) the NAME(s) of the file(s)

opened for outputting to (i.e. opened for writing)?

 

assign(file1, 'data1.txt');

rewrite(file1);

assign(file2, 'data2.txt');

reset(file2);

assign(file3, 'data3.txt);

append(file3);

 

a)       data1.txt

b)       data2.txt

c)       data3.txt

d)       data1.txt and data3.txt

e)       data1.txt and data2.txt

 

1.        The term index and subscript are synonymous.

a. True

b. False

 

 

 

 

2.        Indexed variable and array variable are synonymous

a. True

b. False

 

 

 

 

3.        Functions cannot return arrays

a. True

b. False

 

 

 

 

4.        A data structure is a way of organizing data values

a. True

b. False

 

 

 

 

5.        A dynamic data structure can grow and shrink in size during the course of a program’s execution

a. True

b. False

 

 

 

 

6.        A linked list is a type of dynamic data structure

a. True

b. False

 

 

 

 

7.        Pointers can be passed to functions

a. True

b. False

 

 

 

 

8.        A Pascal compiler will always generate a syntax error if you reference an array out of its bounds/size

a. True

b. False

 

 

 

 

9.        Records cannot contain pointers as components

a. True

b. False

 

 

 

 

10.     String types may NOT be used as parameter types  (e.g procedure dostuff(var first, last : string[10]); )

a. True

b. False

 

 

 

 

11.     Array elements may be accessed either sequentially, as with a for loop, or in a “random” order by computing the desired index

a. True

b. False

 

 

 

 

12.     The interface section of a unit is the private section

a. True

b. False

 

 

 

 

13.     The implementation section of a unit is the private section

a. True

b. False

 

 

 

 

14.     When writing a program that uses unit, the programmer must know the details of the unit's IMPLEMENTATION section

a. True

b. False

 

 

 

 

15.     Constants and Types CANNOT be placed in the interface section of a unit source file

a. True

b. False

 

 

 

 

16.     Arrays illustrate the notion of a structured type

a. True

b. False

 

 

 

 

17.     A unit may only contain functions – no procedures

a. True

b. False

 

 

 

 

18.     Type String is an ordinal type

a. True

b. False

 

 

 

 

 

19.     Value parameters typically consume less storage than variable parameters

a. True

b. False

 

 

 

 

20.     In Pascal the size of an array must be declared at the time the program is written

a. True

b. False

 

 

 

 

21.     The size of an array cannot be changed dynamically (during run-time).

a. True

b. False

 

 

 

 

22.     An entire array can be used as a parameter to a write or writeln statement

a. True

b. False

 

 

 

 

23.     An array variable without subscripts may be used in an assignment statement of the type A:=B; where A and B are arrays of the same type

a. True

b. False

 

 

 

 

24.     A record type can have fields holding different types of data

a. True

b. False

 

 

 

 

25.     A record type is an example of a structured data type

a. True

b. False

 

 

 

 

26.     Records and arrays provide a way of giving a single name to a collection of values

a. True

b. False

 

 

 

 

27.     Pascal allows you to use arrays of arrays

a. True

b. False

 

 

 

 

28.     Pascal only allows you to use one or two dimensional arrays

a. True

b. False

 

 

 

 

29.     In Pascal, the expression A[6, 7] is the same as A[7][6]

a. True

b. False

 

 

 

 

30.     Pascal allows you to create arrays of records

a. True

b. False

 

 

 

 

31.     Enumerated type and subranges of enumerated types may be used as the index types of arrays.

a. True

b. False

 

 

 

 

32.     The following definition is valid.

Type

Index = -5 .. 5;

                Grades = array[index] of integer;

a. True

b. False

 

 

 

 

33.     The following program segment is valid.

Program check;

Var

        A: array[1..10] of integer;

        X: integer;

Begin

        X:= 0;

        A[X]:= 1;

       End.

a. True

b. False

 

 

 

 

34.     If ‘C’ is an array, the statement C:= 0; is illegal.

a. True

b. False

 

 

 

 

35.     The with statement is used for arrays as well as records.

a. True

b. False

 

 

 

 

36.     Index types for arrays cannot be which of the following types.

a. integer

b. chars

c. boolean

d. reals

e. enumerations

 

37.     The following code uses which type of array:

                 Books[4][5]:= 38.4;

a. single-dimensional

b. multi-dimensional

c. array of arrays

d. both A and B

e. both A and C

 

38.     The following code uses which type of array:

                Books[4, 5]:= 38.4;

a. single-dimensional

b. multi-dimensional

c. array of arrays

d. both A and B

e. both A and C

 

39.     The individual components of a record are commonly referred to as

a. fields

b. components

c. component fields

d. all of the above

e. none of the above

 

40.     Components of a record are accessed using which operator.

a. period (.)

b. hyphen (-)

c. arrow (->)

d. all of the above

e. none of the above

 

41.     Which of the following symbols declares a pointer variable.

a. asterisk (*)

b. caret (^)

c. arrow (->)

d. all of the above

e. none of the above

 

42.     Which of the following will create a new dynamic variable.

a. malloc

b. alloc

c. calloc

d. new

e. create

 

43.     Which operator is used to access a component through a pointer.

a. period (.)

b. hyphen (-)

c. arrow (->)

d. caret (^)

e. caret-period (^.)

 

44.     Which reserved word represents a value of  “empty” or “pointing to nothing” for a pointer

a. NULL

b. NIL

c. EMPTY

d. ZERO

e. VOID

 

45.     What is the output of the below program ?

 

program OutPut;

type

   List = array[1..6] of char;

Var

   i : integer;

   word : List;

begin

   word[1] := ‘Y’;

   word[3] := ‘W’;

   word[6] := ‘?’;

   word[5] := ‘H’;

   word[2] := ‘D’;

   word[4] := ‘O’;

   for  i := 1 to 6 do

      write(word[i]);

end.

a. ?YDWOH

b. YDWOH?

c. HOWDY?

d. ?HOWDY

e. There is no output

 

46.     In the statement:   Score[ K ] := 5; K  is the:

a. Index Expression

b. Value of the array element

c. Array Name

d. All of the above

 

e. None of the above

 

 

47.     In the statement:  Score[ K ] := 5; Score is the:

a. Index Expression

b. Value of the array element

c. Array Name

d. All of the above

e. None of the above

 

48.     In the statement:   Score[ K ] := 5; 5 is the:

a. Index Expression

b. Value of the array element

c. Array Name

d. All of the above

e. None of the above

 

49.     What is the output of the below program (assume no syntax errors)?

program SumScores;

const

   MAX_SIZE = 5;

Type

   score_array = array[1..MAX_SIZE] of integer;

var

   i, j, x, num_studs : integer;

   scores : score_array;

 

begin

   for i:= 1 to MAX_SIZE do

      scores[i] := i * 10;

           x := 0;

   num_studs := 3;

 

   for j := 1 to num_studs do

      x := x - scores[j];

 

   writeln(x);

end.

a. none of the below

b. 30

c. 60

d. 100

e. 150

 

50.     Which of the following is NOT a “built in” string function/procedure in Turbo Pascal?

a. copy

b. reverse

c. pos

d. length

e. insert

 

51.     If the following statement is placed in a working program what is the value of p after the statement is executed (assume p is type integer) ?

                    p: = pos(‘do’, ‘dothedo’);

a. 0

b. 1

c. 5

d.  6

e. 7

 

52.     Given the below 4 types of declarations:

5)       Constant Declarations

6)       Variable Declarations

7)       Type Declarations

8)       Procedure and Function Declarations

 

What is the order the book says they should be done in a program?

  1.  1, 2, 3, 4

b. 1,3,2,4

c. 4,2,1,3

d. 4,3,2,1

e. 3,4,2,1

 

53.     Which of the following is the correct declaration for an array?

a.        A= array [1..10] of integer;

b. A= array of  [1..10] integer;

c. A= integer[1..10] of array;

 

d. A = integer array of [1..10];

 

e. none of these

 

 

54.     Given the following type declaration:

type

   BigOnes = 9..15;

 

The host type of BigOnes is:

a.  char

b. boolean

c. integer

d. real

e. string

 

55.     Assume the following code is embedded in a working program.

Also assume that the array A has been properly declared and Element is type integer.

 

Sum := 0;

For Element := A[1] to A[100] do

     Sum := Sum + Element;                       { This is the statement line referred to in the question }

        How many times does the statement in the for loop get executed?

a.  99 times

b.  101 times

c. Can’t say, it depends on the values of A[1] and A[100].

d. once

e. 100 times

 

56.     Which of the following are true:

I.                     Enumerated type variables can be used in assignment statements.

II.                   All ordinal types can used in readln statements.

III.                 A subrange type contains a subrange of values of any data type.

a.  I

b.  II

c. III

d. II and III

e. I , II and III

 

The next 3 questions assume the following declarations:

Type

   ArrayType = array [1..10] of integer;

Var

   A, B, C : ArrayType;

   i, j, sum : integer;

 

57.     What does the following piece of code do given the above declarations and assuming it is embedded in a working program ?

                For i:= 1 to 10 do

                     A[i] := B[10 - i + 1];

a. Copies the array B to A

b. Copies the array A to B

c. Stores in B, the reverse array of B.

d. Stores in A, the reverse array of B.

e. None of the above

 

58.     Given the above declarations and assuming it is embedded in a working program, what does the following piece of code do ?

 for i:=1 to 10 do

begin

   sum := A[i];

   A[i] := B[i];

   B[i] := sum;

End;

a. Reverses the contents of both A and B.

b. Swaps the contents of A and B (i.e. When the loop completes, the content of A = what the content of B was before the loop and the content of B is what the content of A was before the loop)

c. Finds the sum of the contents of A and B.

 

d. Copies the contents of A into B, leaving A unchanged.

e. None of the above.

 

59.     If low and high are integers and low < high then the number of elements in array A[low..high] of integer is:

a. high – low

b. high + low

c. high – low – 1

d. high – low + 1

e. None of the above

 

60.     How many elements are in the following multi-dimensional array?

Var

         Test : array[‘B’..’E’,’a’..’d’] of integer;

a.  2

b. 4

c. 8

d. 16

e. None of the above

 

61.     How many elements are in the following multi-dimensional array?

 Var

          Test : array[20..25, 10..15] of integer;

a. 10

b. 25

c. 36

d. 40

e. 70

 

62.     A program that uses a unit must have access to at least:

a.  The unit's source file

b. The compiled unit

c.  The “.pas” file of the unit

d. The unit’s matriod

e. All of the above

 

63.     A program that uses a unit may reference:

I.                     declarations found in the interface section of the unit

II.                   declarations found in the implementation section of the unit

III.                 any procedure and function found in the unit

a.  I

b.  II

c. III

d. All of the above

 e. None of the above.

 

64.     What will happen if you forget to close a file opened for writing?

a. The program will not compile

b. The program will terminate immediately with a run-time error.

c. It is possible that not everything you wrote to that file is saved to disk.

d.  No file will be created (not even an empty one).

e. There is no need to close a file opened for writing.

 

program FoodBill;

type

   DeptName = (Meat, Deli, Produce, Grocery);

   AmountSpent = array[DeptName] of real;

   ExpenseArray = array[50] of AmountSpent;

var

   SpentOn : AmountSpent;

  CustomerExpense : ExpenseArray;

 

function Total(var B: AmountSpent) : real

var

   Dept: DeptName;

   Sum : real;

begin { Total }

   Sum := 0;

   for Dept := Meat to Grocery do

      Sum := Sum + B[Dept];

   Total := Sum;

end; { Total }

 

begin    { main }

   SpentOn[Meat] := 40.0;

   SpentOn[Deli] := 0.0;

   SpentOn[Produce] := 10.00;

   SpentOn[Grocery] := 45.00;

 

   writeln(Total(SpentOn):0:2);

end. { main }

 

65.     What is the output of the above code.

a.  95.00

b.  100.00

c. 40.00

d. 45.00

e. None of the above.

 

66.     In the above code the variable SpentOn is

a.  An array of arrays

b. A 1-dimensional array

c. A 3-dimensional array

d. A 4-dimensional array

e. Not an array

 

67.     In the above code the variable CustomerExpense is:

a.  An array of arrays

b. A 1-dimensional array

c. A 3-dimensional array

d. A 4-dimensional array

e. Not an array

 

The next 3 questions  refer to the below code:

 

program ArrayStuff;

type

   array_type : array[1..10] of integer;

var

   A, B : array_type;

   index, x, y, z : integer;

begin

   for index := 1 to 10 do

   begin

      A[index] := index + 1;

      B[index] := index;

   end; { for }

 

   B := A;

   B[3] := B[3] –2;

 

   x := B[3];

   y := A[3];

   z := B[4];

   { The questions will ask what the value of x, y, z are at this point in the code }

   writeln(x, y, z);

end.

 

 

68.     What is the value of x that is output?

a.  1

b.  2

c. 3

d. 4

e. 5

 

69.     What is the value of y that is output?

a.  1

b.  2

c. 3

d. 4

e. 5

 

70.     What is the value of z that is output?

a.  1

b.  2

c. 3

d. 4

e. 5

 

71.     Given the below declarations:

 type

   Sample = record

                       F1 : integer;

                       F2 : char;

                    end;

var

   X1, X2 : Sample;

 

Assume the following code is embedded in a working Pascal program:

 

X1.F1 : = 5;

X1.F2 := ‘A’;

write(X1.F1, X1.F2, ‘ ---- ‘);

X2 := X1;

X2.F1 := 6;

X1.F1 := 4;

writeln(X2.F1, X2.F2);

 

What is the output?

a. 6A ---- 5A

b. 5A ---- 5A

c. 5A ---- 6A

d. 6A ---- 6A

e. 5A ---- 4A

 

72.     Given the below declarations

Type

        OneToFifty = 1..50;

        IloveTests = array[1..50] of integer;

Var

        A.B: IloveTests;

        X,Y: OneToFifty;

  Which of the following statements is not allowed?

a.  A[X][Y] :=B[X][Y]

b. A[B[X*Y]] :=X;

c. A := B

d. B:= A

e. None of the above

 

73.     If you have a two-dimensional array in ROW-MAJOR order, the inner loop should control which subscript?

a. Column subscript

b. Row subscript

c. It can control either subscript

d. It can control both subscripts

e. None of the above

 

74.     Which of the following words is NOT associated with pointers in Turbo Pascal?

a. Delete

b.  New

c.  Dispose

d.  Nil

e. None of the above are associated with pointers

 

75.     Given the below declarations, which of the following Pascal Statements is valid?

Type

        Date = Record

                        Month: 1..12;

                        Day: 1..31;

                        Year: integer;

        End;

 

        Info = Record

                        Name: array[1..20] of char;

                        Birthday: Date;

        End;

 

         Var

                D: Date;

                I: Info;

a.I.Birthday.Day:=40;

b. D.Name:= 'Jim';

c.I.Birthday.Year.Month := 10;

d.  D.Date := 23;

e. None of the above

 

 

 

 

 

 

 

The following code segment is for the next two questions.

 

Type

        Ptr = ^node;

        Node = Record

                        Name: string[20];

                        Height: integer;

                        Next: Ptr;

        End;

 

Var

        MyNodePtr, p1, p2: ptr;

                MyNode: Node;

76.     Which of the following statements would create a new dynamic variable of type Node?

a. New(Node);

b.  New(MyNode);

c.  New(MyNodePtr);

d.  New(^Node);

e. New(Record);

 

77.     Assume that all pointers have been allocated and initialized correctly (point to something valid). Assume all other necessary initialization steps have been performed.

       Given the above code, which of the following statements would cause an error?

a. P1 := P2;

b.  MyNode.Height := 110;

c.  P1^.Height := 100;

d.  MyNode.Next := P1;

e. None of the above

 

78.     Which of the following compiler directives force the compiler to always give an error message for “Array Index out of Range Error”

a. {$R+}

b.  {$B+}

c.  {$R-}

d.  {$B-}

e. None of the above

 

79.     When you type in a unit file (say temp) and save it to the disk, what would you save the file as before compiling it?

a. temp.pas

b.  temp.tpu

c.  temp.exe

d.  temp.bak

e. temp.txt

 

80.     Which of the following is/are NOT valid array declarations?

a.  

x: array[2..11, 'r'..'w'] of char;

b. 

x: array[5..22, boolean] of char;

c. x:array[72..78,2.0..4.0] of char;

d. 

Only b and c are NOT valid.

e.

Statements a, b and c are all NOT valid.

 

 

 

 

 

For next 3 assume the following definitions and declarations:

 

Type NodePointer=^Node;

   Node=Record

                   Data:integer;

                    Next:NodePointer;

              END;

Var

     Ptr:NodePointer;

     Cell:Node;

 

Which of the following are legal in Pascal?

 

(a).new(cell);

(b).new(node);

(c) .new(nodepointr);

(d).new(ptr);

(e).none of the above

 

(a).new(node.next);

(b).new(ptr^);

(c )..new(cell.data);

(d).new(ptr);

(e).both © and (d).

 

(a).cell.next=NIL;

(b).ptr:=nil;

(c ).writeln(ptr^.data);

(d).readln(cell.data);

(e).all of the above

 

 

next 4 Questions are based on the following piece of code:

 

Type Data=record

                        Value:integer;

                   End;

 

Var p1,p2:^data;

 

New(p1);

New(p2);

P1^.value:=10;

P2^.value:=20;

Writeln(p1^.value,p2^.value);

P1:=p2;

Writeln(p1^.value,p2^.value);

P1^.value:=30;

Writeln(p1^.value,p2^.value);

P2^.value:=40;

Writeln(p1^.value,p2^.value);

 

 

What is  the first line of output?

 

(a).1010

(b).1020

(c ).2020

(d).2010

(e).1030

 

What is the second line of output?

 

(a).1010

(b).1020

(c )..2020

(d).2010

(e).1030

 

What is the third line of output?

 

(a).3010

(b).3020

(c ).3030

(d).2030

(e).1030

 

What is the fourth line of output?

 

(a).3040

(b).4030

(c ).3030

(d).4040

(e).4020

 

Which of the following are ordinal types?

 

1.Boolean

2.String

3.Real

 

(a). 1

(b). 2

(c ). 3

(d). 1 & 2

(e). 1,2&3

 

 

What is the output of the following code fragment?( I is of type integer and ord(‘A’) is 65)

 

for I:=1 to 5 do

   write(chr(ord(‘A’) + I));

 

(a). ABCDEF

(b). BCDEFG

(c ).656676869

(d).66677983

(e).none of the above

 

 

Which of the following are true?

 

1.Enumerated type variables can be used in assignment statements

2.All ordinal types can be used in readln statements

3.A subrange type contains a subrange of values of any data type

 

(a). 1

(b). 2

(c ).  3

(d).2 & 3

(e).All of the above

 

If low and high are integers and low<high then the number of elements in array A[low..high] of integer is

 

(a).high-low

(b).high+low

(c ).high-low-1

(d).high-low+1

(e).none of the above

 

Which of the following is true?

 

(a).The size of an array may be dynamically changed

(b).A function may return an array value

(c ).We should always pass an array as a formal value parameter

(d).We may pass an array to a procedure using the array name only

(e).An array may be declared to a maximum of three dimensions

 

Use the following piece of code for next 3 questions

 

{$R+}

 

program exam3;

 

const

       MAX:=6;

 

Type

      Indextype:=1..5;

      Arraytype=array[indextype] of char;

 

Var

     Count:integer;

      Message:arraytype;

 

Begin

       Message[1]:=’h’;

       Message[2]:=’e’;

       Message[3]:=’l’;

       Message[4]:=’l’;

       Message[5]:=’o’;

       Message[6]:=’!’;

       For count:=1 to MAX do

              Write(message[count]);

End.

 

What is the output of the program?

 

(a).hello

(b).hello!

(c ). Hell!

(d).subscript range error

(e).none of the above

 

”message” can be best described as:

 

(a).an array of arrayType elements

(b).an array of char elements

(c ).an array of indextype elements

(d).an array of integer elements

(e).none of the above

 

The type “indextype” can be best described as:

 

(a).an array of integers

(b).a subrange type

(c ).a subtype of the type integer

(d).an array of type arraytype

(e).none of the above

 

 

 

·         Which of the following is NOT a legal Pascal variable

1.        _ABC123

2.        A_BC123

3.        A_1BC23

4.        1_ABC23

5.        A_B_C123

 

·         Consider the following program segment

Read(N1, N2)

Read(N3)

If these two lines use the input

1 5 7

9 11

1.        1

2.        5

3.        7

4.        9

5.        11

 

·         In which of the cases will the following statements produce an error if x:=y

1.        Var x: integer;

Var y: real;

2.        Var x: real;

Var y: integer;

3.        Var x: real;

Var y: real

4.        Var x: integer;

Var y: integer;

5.        None of the above

 

·         Which of the following is the output for the code below

 

Count:=0;

A=0;

B=1;

While (Count <=7) do

Begin

        Count:=Count+1;

        A:=A+B;

        B:=A-B;

        A:=A-B;

Write(A);

End.

 

  1. 0 1 1 2 3 5 8 11
  2. 0 0 0 0 0 0 0 0
  3. 1 1 1 1 1 1 1 1
  4. 1 0 1 0 1 0 1 0
  5. 0 1 0 1 0 1 0 1

 

 

·         If you were asked to give someone a hardcopy of your source code, what would you give?

  1. A printout of wyour program
  2. A 3 ½ inch disk with the source code
  3. A CD ROM with the source code burned on it
  4. A 3 ½ inch disk with the program and executable file
  5. The hard disk on which the program was saved

 

 

The next two questions pertain to the following code segment

 

Program confuse;

Var

                X,Y: integer;

 

 

{Procedure Swap places the value of U in Z and the value of Z in U}

Procedure Swap(Var U,V: Integer);

Var

                Temp: Integer;

Begin

                Temp:=U;

                U:=Z;

                Z=Temp;

End;

 

Begin {program}

                X:=10;

Y:=20;

Confuse(X,Y);

Confuse(Y,X);

Confuse(X,Y);

Writeln(‘X = ‘,X);

Confuse(Y,X);

Writeln(‘Y = ‘,Y);

 

·         The formal parameters of Procedure Swap are

  1. U, Z, Temp
  2. X, Y, Temp;
  3. X, Y
  4. U, Z
  5. X, Y, U, Z, Temp

 

 

·         The output of the Program is

  1. X = 10 Y = 20
  2. X = 20 Y = 10
  3. X = 10 Y = 10
  4. X = 20 Y = 20
  5. None of the above

 

 

·         What is the output of the following program segment?

Var X: Integer;

Begin

        X:= 5 + 2 * 4;

        Writeln(X);

End.

  1. 28
  2. 13
  3. 40
  4. 11
  5. None of the above

 

 

·         What is the output of the following program segment?

X:= 10;

While (X>0) do

        X:= X – 4;

Writeln(X);

  1. 6, 2, -2
  2. –2
  3. 0
  4. 2
  5. Error because X becomes negative

 

 

·         A logical error is

  1. A typing mistake
  2. Detectable at computing time
  3. A mistake in the underlying algorithm
  4. When logic circuits of the computer fail
  5. All of the above

 

 

Which of the following is NOT a legal Pascal Variable?

  1. _ABC123
  2. A_BC123
  3. A_2BC13
  4. 2_ABC13
  5. A_BC_321

 

Which of the below declarations will cause the statement:

x := y;

to be in error?

  1. VAR

x: char; 

y: char;

  1. VAR

x: real; 

y: integer

  1. VAR

x: real; 

y: real;

  1. VAR

x: integer; 

y: integer;

  1. VAR

x: integer; 

y: real;

 

What is the output of the below code (assume it is embedded in a working program)

count := 0;

A := 1;

B := 1;

while (count <= 4) do

BEGIN

        count := count + 1;

        B := B + 1;

        A := A + B - count;

        write(A, ' ');    { there is a space between those single quotes }

END;

 

  1. 0 1 2 3 4
  2. 1 2 3 4 5
  3. 2 3 4 5 6
  4. 1 1 1 1 1
  5. 0 0 0 0 0

 

If you were to give someone a hardcopy of your program, you would give them what?

  1. The hard disk on which the program was saved.
  2. A printout of the program.
  3. A CD-ROM with the source code burned on it.
  4. A 3 1/2 inch floppy disk with the program saved on it.
  5. A picture of the program's output.

 

 

 

 

The next 2 questions pertain to the following code (assume the code has NO syntax errors and compiles)

 

Program confuse;

VAR

     x, y : integer;

 

{ Procedure swap places the value of U in Z and the value of Z in U }

Procedure Swap( Var U, Z : Integer);

VAR

     Temp : Integer;

 

BEGIN

     Temp := U;

     U : = Z;

     Z := Temp;

END;

 

BEGIN { Program }

     x := 1;

     y := 2;

     swap( x, y);

     swap( y, x);

     swap( x, y);

     write(' x = ', x);

     swap( y, x);

     writeln(' y = ', y);

END.

 

The FORMAL parameters of Procedure Swap are:

  1. U, Z, Temp
  2. X, Y, Temp
  3. U, Z
  4. X, Y
  5. X, Y, U, Z, Temp

 

The output of the program is:

  1. x = 2 y = 2
  2. x = 1 y = 2
  3. x = 2 y = 1
  4. x = 1 y = 1
  5. none of the above

 

What is the output of the following program segment (assume embedded in working code)

VAR   n : integer;

BEGIN

   n := (7 DIV 3);

   writeln(n);

END;

 

  1. 1
  2. 2
  3. 3
  4. 0
  5. 2.3333333333

 

 

 

 

 

 

by computing the desired index (T / F).

 

 

 

 

 

 

 

 

 

 

 

 

What is the output of the following program segment? (assume embedded in working code)

 

x := 10;

while ( x > 0 ) do

   x := x – 4;

   writeln(x, '   ');    { There are several spaces between the single quotes }

 

  1. 6   2   –2
  2. 6   2
  3. 0
  4. 2
  5. –2

 

Which of the following is NOT part of a procedure?

  1. heading
  2. subject
  3. body
  4. both A and B
  5. A, B and C

 

Which of the following identifiers represents a loop structure?

  1. if-then-else
  2. loop
  3. while-do
  4. procedure
  5. none of the above

 

 

The rules of grammar for a programming language are called the

  1. grammar
  2. rules
  3. statements
  4. ontology
  5. syntax

 

Which of the following is the assignment operator in Pascal?

  1. =
  2. :=
  3. = =
  4. ->
  5. =>

 

In the following statement, which mathematical operation will be performed first (aka has the higher precedence) ?

 

X + Y * Z – W / A;

 

  1. *
  2. /
  3. +
  4. –
  5. log

 

Which identifier BEGINS a comment in Pascal?

  1. //
  2. /*
  3. (*
  4. [
  5. }

 

<, =, >, <> are all examples of what in Pascal

  1. relational operators
  2. comparison operators
  3. test operators
  4. both A and B
  5. A, B and C

 

Which following structures assists the programmer in top-down design?

  1. procedure
  2. while-do
  3. if-then-else
  4. loop
  5. none of the above

 

What type of variable would the following value be assigned to:    'Why, hello there'

  1. integer
  2. real
  3. string
  4. complex
  5. char

 

 

 

 

What would be the output of the following expression?

2 * 4 – sqrt(abs(-16)) / 2

 

  1. 0.0
  2. 6.0
  3. 2.0
  4. 3.0
  5. None of the above

 

Given the following piece of code (embedded in a working program, assume no syntax errors):

VAR

        score : integer;

        grade : char;

BEGIN

        grade := 60;

       if (score >= 60) then

             grade := 'p'

        else

        if (score <= 60) then

              grade := 'f';

END.

 

What is the final value of grade (when the program ends)?

  1. p
  2. f
  3. pf
  4. fp
  5. undetermined

 

How many times is "Howdy" printed by the below code (assume embedded in working program with no syntax errors):

VAR

        count : integer;

BEGIN

        count := 5;

        while (count > 1) do

        begin

           writeln('Howdy');

           count := count – 1;

        end;

END.

 

  1. 3
  2. 4
  3. 5
  4. infinite number of times (or until computer breaks or is turned off)
  5. none of the above

 

 

Which of the following is NOT a reserved word in Pascal?

  1. program
  2. begin
  3. end
  4. const
  5. comment

 

Which of the following statements is FALSE about comments in a program?

  1. they increase readability
  2. they are compiled to machine language by the compiler
  3. they provide program documentation
  4. all the above are true
  5. both b and c are false

 

If the below statement was placed in a working a program (assume ch is type char):

 

ch := succ(‘G’);

 

What is the value of ch after the above statement is executed?

 

  1. F
  2. K
  3. h
  4. H
  5. f

 

If the below statement was placed in a working program (assume val is type integer):

 

val := ord( ‘M’ ) –  ( ord( ‘L’ ) );

 

What is the value of val after the above statement is executed?

 

  1. 0
  2. 1
  3. 2
  4. –1
  5. –2

 

 

 

Given the following type declaration:

type

   BigOnes = 9..15;

 

The host type of BigOnes is:

 

  1. char
  2. boolean
  3. integer
  4. real
  5. string

 

In the statement:   Score[ I + 3 ] := 5;

I + 3 is the:

 

  1. Array Name
  2. Index Expression
  3. Value of the array element
  4. All of the above
  5. None of the above

 

In the statement:  Score[ I + 3] := 5;

Score is the:

 

  1. Array Name
  2. Index Expression
  3. Value of the array element
  4. All of the above
  5. None of the above

 

In the statement:   Score[ I + 3] := 5;

5 is the:

 

  1. Array Name
  2. Index Expression
  3. Value of the array element
  4. All of the above
  5. None of the above

 

Assume the following code is embedded in a working program.

Also assume that the array A has been properly declared and Element is type integer.

 

Sum := 0;

For Element := A[1] to A[100] do

     Sum := Sum + Element;                       { This is the statement line referred to in the question }

 

How many times does the statement in the for loop get executed?

 

  1. once
  2. one hundred times
  3. 99 times
  4. 101 times
  5. Can’t say, it depends on the values of A[1] and A[100].

 

 

What is the output of the following program segment (as always, embedded in working program and no syntax errors):

 

writeln('Howdy, ');      { there is a space before each ending single quote }

write('Good ');

writeln('Luck ');

 

  1. Howdy,

Good

Luck

  1. Howdy, Good Luck
  2. Howdy, Good

Luck

  1. Howdy,

Good Luck

  1. None of the above

 

What is the output of the following program (assume no syntax errors)?

program SeeIt;

VAR

   x, y : integer;

 

procedure Bob(x, y : integer);

BEGIN

   writeln(x, ‘  ‘, y, ‘  ‘);   { There is a space between the single quotes }

END;

 

BEGIN { program }

   x:= 1; y := 2;

   Bob(x, y);

   Bob(y, x);

END.

 

  1. 1  2  1  2
  2. 1  2  2  1
  3. 1  2

1  2

  1. 2  1

1  2

  1. 1  2

2  1

 

Which of the following is NOT a type of parameter (discussed in the book)?

  1. formal
  2. concrete
  3. actual
  4. variable
  5. value

 

What is the decimal (base ten) representation of the binary number:   00101 ?

  1. 5
  2. 6
  3. 7
  4. 11
  5. 3

 

What is the output of the following program?  ( Assume no syntax errors )

program Just;

VAR

   i : integer;

BEGIN

   i := 0;

   while (i < 5)  do

       writeln(i, ‘ ‘);         { There is a space between the single quotes } 

END.

 

  1. 0 1 2 3 4
  2. 0 1 2 3 4 5
  3. 0
  4. no output
  5. the program loops forever outputting 0

 

What is the output of the following program? (Assume no syntax errors)

program YetAgain;

VAR

   i, k : integer;

 

BEGIN

   i := 1;

   k := i + 1;

 

   while (i <= k) do

   begin

       if (i MOD k = 0) then

            i := k + 1

       else

            i := i + 1;

   end;     { of while } 

 

   writeln( i );

END.

 

  1. 1
  2. 2
  3. 3
  4. 4
  5. the while loop is infinite, so nothing is ever output

 

The next TWO questions refer to the below code (assume no syntax errors):

 

program YetAgainAndAgain;

VAR

   i, k : integer;

 

Procedure AddAndIncrement( var u : integer, z : integer );

begin

   u := u + z;

   z := z + 1;

end;

 

BEGIN

   i := 3;

   k := 2;

 

 AddAndIncrement (i, k);

 

   writeln( i, ‘ ‘, k);    { there is a space between the single quotes }

 

end;     { of while } 

 

What is the value of i that is output ?

  1. 2
  2. 3
  3. 4
  4. 5
  5. 6

 

What is the value of k that is output ?

  1. 2
  2. 3
  3. 4
  4. 5
  5. 6

 

What is the output of the following piece of code (assume embedded in working program and no syntax errors):

 

dollars := 9876.54321;

writeln( ‘$’, dollars:0:1);

 

  1. $6.54321
  2. $6.5
  3. $9876.543
  4. $9876.54
  5. $9876.5

 

Which of the following is NOT a correctly formed constant of type REAL (according to Pascal)?

  1. .89
  2. 98.6
  3. –32.0
  4. 5.22
  5. 11.278

 

 

Which of the following can never be used as a variable name in Pascal?

  1. sum
  2. average
  3. next
  4. first
  5. program