[go: up one dir, main page]

0% found this document useful (0 votes)
7 views4 pages

Library Routines

Library routines are predefined functions in programming languages that simplify tasks such as calculations and string manipulation. Examples include MOD, DIV, ROUND, and RANDOM, which perform specific operations like returning remainders or generating random numbers. The document also provides a pseudocode example for a program that calculates MOD and DIV for two integers and generates a random integer between 100 and 300.

Uploaded by

minahnna2023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Library Routines

Library routines are predefined functions in programming languages that simplify tasks such as calculations and string manipulation. Examples include MOD, DIV, ROUND, and RANDOM, which perform specific operations like returning remainders or generating random numbers. The document also provides a pseudocode example for a program that calculates MOD and DIV for two integers and generates a random integer between 100 and 300.

Uploaded by

minahnna2023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 4

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

// Calculate MOD and DIV


mod_result ← a MOD b
div_result ← a DIV b

// Display results
OUTPUT a, " MOD ", b, " = ", mod_result
OUTPUT a, " DIV ", b, " = ", div_result

// Generate a random integer between 100 and 300


random_number ← RANDOM(100, 300)
OUTPUT "Random integer between 100 and 300: ",
random_number

You might also like