Tag: programming languages

Questions Related to programming languages

Which of the following statements about PL/I arrays is TRUE ?

  1. multidimensional arrays are allowed. The maximum number of dimensions is 15.

  2. the elements in an array can only be of the numeric datatype

  3. a reference towards an element in an array is done by means of a subscript. The first occurrence of an element in an array has subscript 0.

  4. arrays are used to read in DB2 tables


Correct Option: A

Which of the following statements about PL/I programs are TRUE?

  1. a program must always begin with a PROCEDURE statement and end with an END statement

  2. PL/I instructions can be coded between positions 1 and 72

  3. you have to declare each variable that you are going to use

  4. a program can be composed out of different procedures


Correct Option: A

A PL/I programmer wants to display a number in his/her program. Which of the following variables is suited for doing this ? +123.45 (we assume the decimal sign is ‘.’)

  1. PIC ‘(5)9’

  2. PIC ‘S(3)9V.99’

  3. PIC ‘S999.99’

  4. PIC ‘999V99’


Correct Option: B
  1. REPEAT 5 TIMES; instruction; END;

  2. DO J=1 TO 5; instruction; END;

  3. COUNTER = 1; DO WHILE COUNTER < 5; COUNTER = COUNTER + 1; instruction; END;

  4. REPEAT VARYING COUNTER FROM 1 BY 1 UNTIL COUNTER = 5; instruction; END;


Correct Option: B
Explanation:

To repeat an instruction 5 times in PL/I, the programmer can use a loop construct.

Option A is not a valid PL/I syntax.

Option B is a correct way to repeat an instruction 5 times in PL/I. It uses a DO loop with a loop control variable J that iterates from 1 to 5, executing the instruction each time.

Option C is also a valid way to repeat an instruction 5 times in PL/I, but it uses a WHILE loop instead of a DO loop. It initializes a counter variable to 1 and repeats the instruction while the counter is less than 5.

Option D is also a valid way to repeat an instruction 5 times in PL/I, but it uses a REPEAT loop with a loop control variable COUNTER that iterates from 1 to 5, executing the instruction each time.

Therefore, the correct answer is:

The Answer is: B

Take a look at the following PL/I program. Assume A, B, C, ... being PL/I instructions. In which order will they be executed? MYPROG : PROCEDURE OPTIONS (MAIN); CALL INIT; Z; CALL TERM; Z; END MYPROG; INIT : PROCEDURE; A; B; CALL READ-X; LOOP : PROCEDURE; E; F; TERM : PROCEDURE; G; H; READ-X : PROCEDURE. X;

  1. A B Z E F Z X

  2. A B X Z E F G H Z X

  3. A B X Z E F Z G H Z

  4. A B X Z G H Z


Correct Option: D

Take a look at the following PL/I variables. Which of the given conditions is NOT correct? DCL INFILE FILE RECORD INPUT; DCL EOF BIT(1) INIT (‘0’B); ON ENDFILE (INFILE) EOF = ‘1’B; (1) DO WHILE (NOT EOF); (2) DO WHILE (^EOF); (3) DO WHILE (EOF = ‘0’B); (4) DO WHILE (EOF ^= ‘1’B);

  1. 1

  2. 2

  3. 3

  4. 4


Correct Option: A

Assume a PL/I program that wants to execute a call to an external procedure. This procedure expects 1 parameter and returns 1 parameter. Which instructions do you have to provide in the main program ? (1) DCL MYSUB ENTRY (CHAR(5)) EXTERNAL; (2) DCL MYSUB ENTRY (CHAR(5)) RETURNS (CHAR(5)) EXTERNAL; (3) DCL MYPARAMETER,MYRESULT CHAR(5); (4) CALL MYSUB (MYPARAMETER); (5) MYRESULT = MYSUB; (6) MYRESULT = MYSUB(MYPARAMETER);

  1. 1, 3 and 4

  2. 2, 3 and 4

  3. 2, 3 and 6

  4. 1, 3 and 5


Correct Option: C

If you have the following declarations, what will be the content of RESULT at the end of the given instructions? DCL 1 VAR1 CHAR(5) INIT (‘PL/I’); DCL 1 VAR2 CHAR(10); DCL 1 VAR3 CHAR (2); DCL 1 RESULT CHAR (5); RESULT = ‘COBOL’; VAR2 = VAR1; VAR3 = VAR2; RESULT = VAR3;

  1. PLbbb (bbb = 3 blanco’s)

  2. COBOL

  3. COBPL

  4. PLBOL


Correct Option: A

Which of the following PL/I SELECT statements is correct ?

  1. SELECT (A); WHEN (A=0) PUT LIST(‘A = 0‘); WHEN (A=5) PUT LIST (‘A = 5‘); OTHERWISE PUT LIST (‘A IS NOT 0 NOR 5’); END;

  2. SELECT (A); WHEN (0) PUT LIST(‘A = 0‘); WHEN (5) PUT LIST (‘A = 5‘); OTHERWISE PUT LIST (‘A IS NOT 0 NOR 5’); END;

  3. SELECT; WHEN (A=0) PUT LIST(‘A = 0‘); WHEN (5) PUT LIST (‘A = 5‘); OTHERWISE PUT LIST (‘A IS NOT 0 NOR 5’); END;

  4. All of the above


Correct Option: B

Which of the following array declarations is NOT correct ? (1) DCL ARRAY_1 DEC FIXED (3)(5,2); (2) DCL ARRAY_1 (5,2) DEC FIXED (3); (3) DCL ARRAY_1 (5) DEC FIXED (3), (2) DEC FIXED (3); (4) DCL (5,2) ARRAY_1 DEC FIXED (3);

  1. 1

  2. 2

  3. 3

  4. 4


Correct Option: B