Library Routines
Library Routines
Library routines
• Library routines are predefined, reusable functions provided by
a programming language to perform common tasks like
calculations, string manipulation, and file handling.
• They are fully tested, optimized, and help simplify
programming.
» MOD – returns remainder of a division
» DIV – returns the quotient (i.e. the whole number part)
of a division
» ROUND – returns a value rounded to a given number of
decimal places
» RANDOM – returns a random number.
Library routines -Example
• Here are some examples of these library routines in
pseudocode:
• Value1 MOD(10,3) returns the remainder of 10 divided
by 3
• Value2 DIV(10,3) returns the quotient of 10 divided by
3
• Value3 ROUND(6.97354, 2) returns the value rounded
to 2 decimal places
• Value4 RANDOM() returns a random number between
0 and 1 inclusive
• Write and test a short program in your chosen programming
language to:
» input two integers a and b and then find a MOD b and a DIV
b
BEGIN
// Input two integers
» create a random integer between 100 and 300.
OUTPUT "Enter first integer (a): "
INPUT a
OUTPUT "Enter second integer (b): "
INPUT b
// Display results
OUTPUT a, " MOD ", b, " = ", mod_result
OUTPUT a, " DIV ", b, " = ", div_result