Computer Knowledge

Programming Fundamentals

2,611 Questions

Programming fundamentals form the core logic of software development and computer science. This includes variable declarations, pointer assignments, loop iterations, and exception handling. These technical topics are regularly tested in computer knowledge and IT officer competitive examinations.

Variables and arraysPointer assignmentsLoop iterationsException handling blocksCompile time errorsFunction references

Programming Fundamentals Questions

Multiple choice technology mainframe
  1. Subroutine should start with this instruction

  2. To convert all the local variables in the subroutine as global variables

  3. To convert all the variables used in subroutine as local variables

  4. Function should start with this instrucion

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

PROCEDURE marks the start of a subroutine and ensures all variables within it are local to that routine unless exposed on the PROCEDURE statement. Without it, variables would be global across the entire exec.

Multiple choice technology programming languages
  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

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Every executable PL I program requires a PROCEDURE statement with OPTIONS MAIN to start and an END to terminate. Code is written in columns 2 72, variables need not always be declared due to default typing, and while procedures can contain internal procedures, the main program structure is what option A describes.

Multiple choice technology programming languages
  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;

Reveal answer Fill a bubble to check yourself
B Correct answer
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

Multiple choice technology programming languages
  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

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

MYPROG calls INIT which executes A, B, then READ X which executes X, then instruction Z, then TERM which executes G, H, then instruction Z again. LOOP is defined but never called, so E and F never execute.

Multiple choice technology programming languages
  1. 1, 3 and 4

  2. 2, 3 and 4

  3. 2, 3 and 6

  4. 1, 3 and 5

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

To call an external procedure that returns a value, you must: (2) Declare it with RETURNS clause specifying the return type, (3) Declare both the parameter and result variables, and (6) Call it as a function assignment with the parameter. Option A is incomplete (no RETURNS, wrong call syntax), Option B uses wrong call syntax (CALL with function), Option D omits RETURNS.

Multiple choice technology programming languages
  1. PLbbb (bbb = 3 blanco’s)

  2. COBOL

  3. COBPL

  4. PLBOL

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

VAR1 is 'PL/I' (5 chars). VAR2 receives 'PL/I' but is 10 chars, so it becomes 'PL/I ' (padded with 5 blanks). VAR3 is CHAR(2), so it receives only the first 2 characters 'PL'. RESULT, which is CHAR(5), gets 'PL' from VAR3, then padded with 3 blanks → 'PLbbb'. The variable length truncation at assignment to VAR3 is the key behavior.

Multiple choice technology programming languages
  1. 1

  2. 2

  3. 3

  4. 4

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Option 2 (DCL ARRAY_1 (5,2) DEC FIXED (3)) is NOT correct because PL/I requires the data type attributes to precede the dimension bounds. The correct form is either option 1 (type first, then bounds) or option 3 (bounds with separate type clauses). Option 4 is also invalid syntax.

Multiple choice technology programming languages
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Interpreted languages like Perl generally execute slower than compiled languages because they must parse and translate code at runtime. However, modern JIT compilation and optimized engines make the absolute statement 'never execute as fast' technically debatable, though traditionally accepted as true in this context.