Given the following declarations, a list of 100 elements must be created so that the element created last
can be accessed as the first element of the list. A new element is always inserted in front of the element
created before. The variable NEXT in the last element should contain the value NULL. Which of the
following pieces of code implements this?
DCL 1 NODE BASED (ANCHOR).
2 NEXT POINTER,
2 DATA FIXED BIN (31);
DCL ANCHOR POINTER;
DCL P POINTER INIT (NULL());
DCL I FIXED BIN(31);
A. DO I = 1 TO 100;ALLOCATE NODE;NODE.DATA = I;NODE.NEXT = P;P = ANCHOR;END;
B. DO I = 1 TO 100;P = ANCHOR;ALLOCATE NODE;NOTE.DATA = I;NODE.NEXT = P;END;
C. I = 1 TO 100;ALLOCATE NODE;NODE.DATA = I;NODE.NEXT = P;ANCHOR = P;END;
D. DO I = 1 TO 100;NODE.DATA = I;NODE.NEXT = P;ALLOCATE NODE;P = ANCHOR;END;
What is the output of the following program?
DCL A AREA(8000);
DCL 1 STR1 BASED(P),
2 STR1_LGTH BIN FIXED(31),
2 STR_CHAR CHAR(ALLOC_LGTH REFER(STR1_LGTH));
DCL ALLOC_LGTH BIN FIXED(31);
DCL I FIXED BIN(31);
DCL P PTR;
ALLOC_LGTH = 100;
DO I = 1 TO 10;
ALLOC STR1 IN(A);
END;
PUT SKIP LIST(CSTG(A));
A. 1016
B. 1040
C. 1056
D. 8000
Which compiler option causes the compiler to flag any IF, WHILE, UNTIL and WHEN clauses that do not have the attributes BIT(1) NONVARYING?
A. RULES(NOLAXWHILE)
B. RULES(NOLAXIF)
C. RULES(NOLAXUNTIL)
D. RULES(NOLAXWHEN)
Given the following code, which statement will produce an E level preprocessor message?
%DCL ABC ENTRY;
%ABC: PROC (X,Y) STATEMENT RETURNS(CHAR); DCL(XY) CHAR; IF ^PARMSET(X) THEN NOTE
('NO X `,0);
IF ^PARMSET(Y) THEN NOTE('NO Y `8');
RETURN('/* `!!X!!YI!'C */');
%END ABC;
A. ABC Y(B)X(A);
B. ABC (A,);
C. ABC (A,B);
D. ABC(,B);
What happens to STATIC variables declared in a procedure when the procedure is called recursively?
A. STATIC variables are allocated only once and can, therefore, be used for communication between invocations.
B. The values of STATIC variables from the previous invocation are saved and are available when the current invocation ends.
C. The values of STATIC variables from the previous invocation are lost.
D. STATIC variables are allocated and initialized at each new invocation.
Given the following code whatwill be output, if an,thing?
DCLX FIXED DEC (5,2) INIT (-123.45);
DCL S CHAR (7);
PUT STRING (S) EDIT (X) (A(7));
PUT DATA (5);
A. S=' -123.4'
B. S='123.45'
C. S='-123.45';
D. The program ends abnormally at runtime with condition CONVERSION.
Given the following declaration, how many bytes will be occupied by this structure under the default alignment rules?
DCL 1 A DIM (10), 2 B FIXED BIN (31), 2 C CHAR (1)VAR;
A. 70
B. 77
C. 79
D. 80
Given the following code, what measure will improve stability?
S1: PROC (I) RETURNS(CHAR(10));
DCL I BIN FIXED (15);
DCL T (-1:1) CHAR(10) INIT('NOTFOUND' ,`OK'.'ENDFILE'); RETURN(T(l));
END S1;
A. Check the length of the RETURN value.
B. Check I for valid numeric data.
C. Check, if the value of I is within T's bounds.
D. Check, if the value of I is nositive.
A module which is serially reusable has which of the following characteristics?
A. Is intended for single use only and must be refreshed from disk before it can be invoked again
B. Must contain the necessary logic to reset control variables and data areas at entry or exit and a second task may not enter the module until the first task has finished
C. Is designed for concurrent execution by multiple tasks
D. All or part of it may be replaced at any time by the operating system
Given the following statements, where will the variables A, B and C be allocated?
DCL A FIXED;
DCL B CHAR(80) BASED(P);
DCL C CHAR(1000) CONTROLLED;
DCL D AREA(1000);
DCL P PTR STATIC;
ALLOC C;
ALLOC B IN(D);
A. A in STACK, B and C are in HEAP
B. A in HEAP, Band C are in STACK
C. A and B are in STACK, C in HEAP
D. A in STACK, B in STATIC, C in HEAP