Computer Science – Programming | e-Consult
Programming (1 questions)
Login to see all questions.
Click on a question to view the answer
A library routine is a pre-written block of code that performs a specific task. Programmers use library routines to avoid having to write the same code repeatedly. This saves time, reduces the risk of errors, and promotes code reusability. Library routines are often provided by the operating system or programming language itself.
Examples:
- Input/Output (I/O) routines: These routines handle the interaction between a program and the outside world, such as reading data from a keyboard or displaying output on the screen. Examples include routines for reading a character from the keyboard (e.g., scanf in C) or displaying text on the console (e.g., printf in C).
- Mathematical routines: These routines perform mathematical calculations, such as calculating the square root of a number or trigonometric functions. Examples include routines for calculating the square root (e.g., sqrt in C) or sine/cosine (e.g., sin, cos in C).