Library Functions
Introduction to C
Structure of a C Program
Variables and Data Types
Input and Output
Operators in C
Decision Making
If Statement
if...else Statement
Nested if Statement
Nested if...else Statement
Switch Statement
Loops
For Loop
While Loop
Do While Loop
Loop Comparison
Arrays
Strings
Functions
Function Types
Library Functions
User-Defined Functions
Recursion Function
Pointers
Structures
File Handling
Common Mistakes
Ideas
Library Functions
Common C Library Functions
What are Library Functions?
Library Functions (also known as built-in functions) are functions that are already declared and defined in C header files (like <stdio.h>, <math.h>, and <string.h>).
To use them, you simply need to include the corresponding header file at the top of your program using the #include directive.
How to Use Them
#include <header_name.h>
// Inside main or any function:
function_name(arguments);
// Inside main or any function:
function_name(arguments);
Practical Examples by Category
1. Input/Output (<stdio.h>)
The most fundamental functions used for interacting with the user.
// printf() displays data; scanf() reads data printf("Enter age: "); scanf("%d", &age);
2. Mathematical Functions (<math.h>)
Used for advanced calculations like square roots or power functions.
double result = sqrt(25.0); // Returns 5.0 double p = pow(2, 3); // Returns 8.0 (2 raised to 3)
3. String Handling (<string.h>)
Necessary for measuring or comparing text sequences.
char str[] = "SkillEco"; int len = strlen(str); // Returns the length of the string (8)
Important Note: When using math functions like
sqrt() or pow(), ensure you use the %f or %lf format specifiers in printf, as these functions typically return floating-point values.
🏋️ Test Yourself With Exercises
Take our quiz on Library Functions to test your knowledge.
Browse Quizzes »