PL/I Interview Questions (1 - 10)
1. What is PL/I?
PL/I stands for Programming Language One. It is a high-level programming language developed in the 1960s to combine the features of COBOL (used for business applications) and FORTRAN (used for scientific applications). PL/I is designed for both commercial and scientific applications, offering versatility in various computing tasks.
2. What are the key features of PL/I?
- Supports both business and scientific applications
- Powerful string handling
- Built-in error handling
- Supports structured programming
- Can handle complex data structures
3. How do you declare variables in PL/I?
Use the DECLARE statement:
DECLARE variable_name type attributes;
Examples:
DECLARE age FIXED DECIMAL(3); /* Whole number (3 digits) */
DECLARE price FLOAT DECIMAL(7,2); /* Decimal number (7 digits, 2 after .) */
DECLARE name CHARACTER(20); /* Text string (20 characters) */
DECLARE active BIT(1); /* Boolean (1-bit) */
4. What are the basic data types in PL/I?
Main data types:
- FIXED DECIMAL - Whole numbers (integers)
- FLOAT DECIMAL - Decimal numbers
- CHARACTER - Text strings
- BIT - Binary values (1/0)
- POINTER - Memory addresses
- FILE - For file handling
5. How do you write comments in PL/I?
Two ways:
- /* This is a comment */ - For single or multi-line
- // This is a comment - For single line (in modern implementations)
Example:
/* This program calculates
employee bonuses */
DECLARE salary FLOAT; // Current salary
6. What is the difference between FIXED and FLOAT data types?
FIXED DECIMAL | FLOAT DECIMAL |
---|---|
Exact numbers (no rounding) | Approximate numbers |
Good for money/accounting | Good for scientific calculations |
Example: DECLARE age FIXED(3); | Example: DECLARE pi FLOAT(6); |
Slower for complex math | Faster for complex math |
7. What is a PL/I subroutine?
A subroutine in PL/I is a reusable block of code that performs a specific task. Subroutines can be invoked from different parts of a program, promoting code modularity and reuse. In PL/I, subroutines are defined using the PROCEDURE statement.
8. What is the difference between a subroutine and a function in PL/I?
- Subroutine: Performs a task and does not return a value. It is invoked using the CALL statement.
- Function: Performs a task and returns a value. It can be used in expressions and is invoked by its name.
9. Can a subroutine return a value in PL/I?
No, a subroutine itself does not return a value. However, it can modify variables passed to it by reference, effectively allowing it to output results. For returning values directly, functions are used instead.
10. What is the difference between DO WHILE and DO UNTIL?
Feature | DO WHILE | DO UNTIL |
---|---|---|
Condition checked | Before the loop starts | After each loop run |
Minimum executions | 0 times (if condition is false) | At least 1 time |
Use when | You want to test first | You want to run first, then test |