Exploring the Various
Types of Libraries in
the C Language
23H51A0524 {G.SURAJ}
Introduction to Libraries in C
Libraries are collections of pre-written functions and declarations that can be reused in a
program. By using libraries, programmers can save time and effort by not having to write
functions from scratch.
Standard Libraries in C
<stdio.h>
This header file provides input/output functionalities to your program, such as printing to the standard output and
reading input from the user.
<math.h>
This header file contains mathematical functions and constants used in C programming, such as trigonometric
functions and logarithmic functions. ex: pow(x,y),sqrt(x,y),etc…
<string.h>
This header file contains some useful string functions that can be directly used in a program by invoking the
#include preprocessor directive.
<stdlib.h>
This header file contains functions such as memory allocation, program termination, and random number
generation.
<time.h>
In C programming language <time.h> is a header file defined in the C Standard Library that contains time and date
function declarations to provide standardized access to time/date manipulation and formatting.
Sum of two integers:
#include<stdio.h>
int main(){
int a,b;
printf("Enter two numbers:n");
scanf("%d %d",&a,&b);
int sum=a+b;
printf("the sum of a and b is
%d",sum);
return 0;
}
Output:
Enter two numbers:
4
5
the sum of a and b is 9
Counting the number of
characters:
#include<stdio.h>
#include <string.h>
int main() {
char *str="Suraj";
int a=strlen(str);
printf("the length of the string is
%d",a);
return 0;
}
Output:
the length of the string is 5
Cube of the number:
#include <stdio.h>
#include <math.h>
int main()
{
int n;
printf("Enter the number:n");
scanf("%d",&n);
int cube=pow(n,3);
printf("the cube of the %d is
%d",n,cube);
return 0;
}
Output:
Enter the number:
3
the cube of the 3 is 27
Example of <stdio.h>,<string.h>,<math.h>
Example of <stdlib.h> and
<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main() {
int number,guess,nguess=1;
srand(time(0));
number=rand()%100+1;
//printf("the number is %d",number);
do {
printf("Guess the number between (1-
100)n");
scanf("%d",&guess);
if(guess<number) {
printf("Enter the higher number
please!n"); }
else if(guess>number) { printf("Enter
the lower number please!n"); }
else { printf("You have completed it in
%d attempts",nguess); }
nguess++;
}while(number!=guess);
return 0;
}
User-Defined Libraries in C
User-defined libraries are collections of functions, data structures, and other code
elements that you create to be reused in multiple programs.
Static Libraries in C
Static libraries in C are precompiled libraries that contain object code and can be linked with a program at compile time.
They are created using the "ar" command and typically have the extension .a. These libraries can be used to store commonly
used code that can be included in multiple programs, providing modular and reusable functionality.
Dynamic Libraries in C
Dynamic libraries in C are libraries that are loaded and linked with a program during runtime, rather than at compile
time. They are typically shared object files with the extension .so and can be used by multiple programs simultaneously.
Dynamic libraries allow for more flexible and efficient code sharing, as they can be updated independently without
recompiling the entire program.
The C standard libraries provide a wide range of functionality that can be used to accomplish various tasks.
The best use of C standard libraries depends on the type of application you're developing. It's important to choose
the right libraries for your specific use case and make use of them to save time and effort in implementing
common tasks.
Uses of the Libraries in C language:
APPLICATIONS OF LIBRARIES IN C LANGUAGE:
Graphics and Computer-Aided Design (CAD):
• Libraries like OpenGL provide low-level graphics programming for rendering 2D and 3D graphics.
• The first release of AutoCAD is purely written in C and some parts in assembly ,later extended to C++ ,
however AutoCAD has rich scale of wrappers exposed in AutoLISP, Visual LISP, VBA, .NET and JS.
 Audio and Multimedia:
• Libraries like SDL (Simple DirectMedia Layer) enable developers to create multimedia applications,
including games and media players.
• It is a cross-platform development library designed to provide low level access to audio, keyboard, mouse,
joystick, and graphics hardware via OpenGL and Direct3D.It can be used to make animations and video
games.
Networking and Communication:
• Socket Programming:
 Libraries like socket.h enable network communication, allowing developers to create
networked applications, including web servers, chat applications, and more.
Thank You

About the C Libraries which are essential

  • 1.
    Exploring the Various Typesof Libraries in the C Language 23H51A0524 {G.SURAJ}
  • 2.
    Introduction to Librariesin C Libraries are collections of pre-written functions and declarations that can be reused in a program. By using libraries, programmers can save time and effort by not having to write functions from scratch.
  • 3.
    Standard Libraries inC <stdio.h> This header file provides input/output functionalities to your program, such as printing to the standard output and reading input from the user. <math.h> This header file contains mathematical functions and constants used in C programming, such as trigonometric functions and logarithmic functions. ex: pow(x,y),sqrt(x,y),etc… <string.h> This header file contains some useful string functions that can be directly used in a program by invoking the #include preprocessor directive. <stdlib.h> This header file contains functions such as memory allocation, program termination, and random number generation. <time.h> In C programming language <time.h> is a header file defined in the C Standard Library that contains time and date function declarations to provide standardized access to time/date manipulation and formatting.
  • 4.
    Sum of twointegers: #include<stdio.h> int main(){ int a,b; printf("Enter two numbers:n"); scanf("%d %d",&a,&b); int sum=a+b; printf("the sum of a and b is %d",sum); return 0; } Output: Enter two numbers: 4 5 the sum of a and b is 9 Counting the number of characters: #include<stdio.h> #include <string.h> int main() { char *str="Suraj"; int a=strlen(str); printf("the length of the string is %d",a); return 0; } Output: the length of the string is 5 Cube of the number: #include <stdio.h> #include <math.h> int main() { int n; printf("Enter the number:n"); scanf("%d",&n); int cube=pow(n,3); printf("the cube of the %d is %d",n,cube); return 0; } Output: Enter the number: 3 the cube of the 3 is 27 Example of <stdio.h>,<string.h>,<math.h>
  • 5.
    Example of <stdlib.h>and <time.h> #include<stdio.h> #include<stdlib.h> #include<time.h> int main() { int number,guess,nguess=1; srand(time(0)); number=rand()%100+1; //printf("the number is %d",number); do { printf("Guess the number between (1- 100)n"); scanf("%d",&guess); if(guess<number) { printf("Enter the higher number please!n"); } else if(guess>number) { printf("Enter the lower number please!n"); } else { printf("You have completed it in %d attempts",nguess); } nguess++; }while(number!=guess); return 0; }
  • 6.
    User-Defined Libraries inC User-defined libraries are collections of functions, data structures, and other code elements that you create to be reused in multiple programs. Static Libraries in C Static libraries in C are precompiled libraries that contain object code and can be linked with a program at compile time. They are created using the "ar" command and typically have the extension .a. These libraries can be used to store commonly used code that can be included in multiple programs, providing modular and reusable functionality. Dynamic Libraries in C Dynamic libraries in C are libraries that are loaded and linked with a program during runtime, rather than at compile time. They are typically shared object files with the extension .so and can be used by multiple programs simultaneously. Dynamic libraries allow for more flexible and efficient code sharing, as they can be updated independently without recompiling the entire program.
  • 7.
    The C standardlibraries provide a wide range of functionality that can be used to accomplish various tasks. The best use of C standard libraries depends on the type of application you're developing. It's important to choose the right libraries for your specific use case and make use of them to save time and effort in implementing common tasks. Uses of the Libraries in C language:
  • 8.
    APPLICATIONS OF LIBRARIESIN C LANGUAGE: Graphics and Computer-Aided Design (CAD): • Libraries like OpenGL provide low-level graphics programming for rendering 2D and 3D graphics. • The first release of AutoCAD is purely written in C and some parts in assembly ,later extended to C++ , however AutoCAD has rich scale of wrappers exposed in AutoLISP, Visual LISP, VBA, .NET and JS.  Audio and Multimedia: • Libraries like SDL (Simple DirectMedia Layer) enable developers to create multimedia applications, including games and media players. • It is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.It can be used to make animations and video games. Networking and Communication: • Socket Programming:  Libraries like socket.h enable network communication, allowing developers to create networked applications, including web servers, chat applications, and more.
  • 9.