Learn Pli - 10 Code Examples & CST Typing Practice Test
PLI (Programming Language One) is a procedural, compiled language designed for business and systems programming, particularly for large-scale data processing and legacy IBM mainframe environments.
Learn PLI with Real Code Examples
Updated Nov 21, 2025
Code Sample Descriptions
PL/I Counter and Theme Toggle
DECLARE count FIXED BINARY(31) INITIAL(0);
DECLARE isDark BIT(1) INITIAL('0'B);
UPDATEUI: PROCEDURE OPTIONS(MAIN);
PUT SKIP LIST('Counter: ', count);
IF isDark = '1'B THEN
PUT SKIP LIST('Theme: Dark');
ELSE
PUT SKIP LIST('Theme: Light');
END;
END UPDATEUI;
INCREMENT: PROCEDURE;
count = count + 1;
CALL UPDATEUI();
END INCREMENT;
DECREMENT: PROCEDURE;
count = count - 1;
CALL UPDATEUI();
END DECREMENT;
RESET: PROCEDURE;
count = 0;
CALL UPDATEUI();
END RESET;
TOGGLETHEME: PROCEDURE;
IF isDark = '0'B THEN
isDark = '1'B;
ELSE
isDark = '0'B;
END;
CALL UPDATEUI();
END TOGGLETHEME;
/* Simulate actions */
CALL UPDATEUI();
CALL INCREMENT();
CALL INCREMENT();
CALL TOGGLETHEME();
CALL DECREMENT();
CALL RESET();
Demonstrates a simple counter with theme toggling using PL/I variables and procedures.
PL/I Random Number Generator
DECLARE i FIXED BINARY(31);
DECLARE num FIXED BINARY(31);
DO i = 1 TO 3;
num = RANDOM(100) + 1;
PUT SKIP LIST('Random', i, ':', num);
END;
Generates random numbers between 1 and 100 and prints them.
PL/I Todo List
DECLARE todos CHAR(20) DIM(10);
DECLARE count FIXED BINARY(31) INITIAL(0);
ADD: PROCEDURE(task);
todos(count) = task;
count = count + 1;
PUT SKIP LIST('Todos count: ', count);
END ADD;
REMOVE: PROCEDURE(idx);
DO i = idx TO count-2;
todos(i) = todos(i+1);
END;
count = count - 1;
END REMOVE;
/* Simulate actions */
CALL ADD('Buy milk');
CALL ADD('Write PL/I code');
CALL REMOVE(1);
Maintains a simple todo list with add and remove functionality.
PL/I Dice Roller
DECLARE i FIXED BINARY(31);
DECLARE roll FIXED BINARY(31);
DO i = 1 TO 3;
roll = RANDOM(6) + 1;
PUT SKIP LIST('Roll', i, ':', roll);
END;
Rolls a six-sided dice three times.
PL/I Countdown Timer
DECLARE count FIXED BINARY(31) INITIAL(5);
DO WHILE(count >= 0);
PUT SKIP LIST('Countdown:', count);
count = count - 1;
END;
PUT SKIP LIST('Done!');
Counts down from 5 to 0.
PL/I Prime Checker
DECLARE nums FIXED BINARY(31) DIM(3) INIT(7,10,13);
DECLARE n,i FIXED BINARY(31);
DECLARE isPrime BIT(1);
DO n = 1 TO 3;
isPrime = '1'B;
DO i = 2 TO nums(n)-1;
IF nums(n) MOD i = 0 THEN isPrime = '0'B;
END;
IF isPrime = '1'B THEN PUT SKIP LIST(nums(n), 'is Prime')
ELSE PUT SKIP LIST(nums(n), 'is Not Prime');
END;
Checks if numbers are prime.
PL/I Temperature Converter
DECLARE c FIXED DEC(7,2);
DECLARE f FIXED DEC(7,2);
c = 25; f = c*9/5+32; PUT SKIP LIST('25°C =', f, '°F');
f = 77; c = (f-32)*5/9; PUT SKIP LIST('77°F =', c, '°C');
Converts Celsius to Fahrenheit and Fahrenheit to Celsius.
PL/I Shopping Cart
DECLARE cart CHAR(20) DIM(10);
DECLARE prices FIXED BINARY(31) DIM(10);
DECLARE count FIXED BINARY(31) INITIAL(0);
ADDITEM: PROCEDURE(item, price);
cart(count) = item;
prices(count) = price;
count = count + 1;
END ADDITEM;
REMOVEITEM: PROCEDURE(idx);
DO i = idx TO count-2;
cart(i) = cart(i+1);
prices(i) = prices(i+1);
END;
count = count -1;
END REMOVEITEM;
CALL ADDITEM('Apple',2);
CALL ADDITEM('Banana',3);
CALL REMOVEITEM(0);
Adds and removes items in a shopping cart with total cost.
PL/I Name Greeting
GREET: PROCEDURE(name);
PUT SKIP LIST('Hello,', name, '! Welcome!');
END GREET;
CALL GREET('Saurav');
CALL GREET('Alice');
CALL GREET('Bob');
Greets users by name.
PL/I Stopwatch
DECLARE time FIXED BINARY(31) INITIAL(0);
DO WHILE(time < 5);
PUT SKIP LIST('Stopwatch:', time, 'seconds');
time = time + 1;
END;
PUT SKIP LIST('Done!');
Simulates a stopwatch incrementing seconds.
Frequently Asked Questions about Pli
What is Pli?
PLI (Programming Language One) is a procedural, compiled language designed for business and systems programming, particularly for large-scale data processing and legacy IBM mainframe environments.
What are the primary use cases for Pli?
Large-scale batch processing. Business and financial systems. Mainframe application maintenance. Data processing for enterprises. Legacy system integration and updates
What are the strengths of Pli?
Highly reliable for business-critical applications. Optimized for IBM mainframes. Structured syntax reduces errors. Good for batch and report processing. Supports modular programming with procedures
What are the limitations of Pli?
Mainframe-dependent and outdated for modern platforms. Limited modern tooling or IDE support. Not suitable for web, mobile, or GUI applications. Smaller community compared to modern languages. Steeper learning curve for new programmers
How can I practice Pli typing speed?
CodeSpeedTest offers 10+ real Pli code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.