Computer Science, asked by nitish171999, 6 months ago

difference between library and user defined functions?give 5 library function name and their uses

Answers

Answered by Anonymous
5

Library function:

These function are the built-in functions i.e., they are predefined in the library of the C. These are used to perform the most common operations like calculations, updatation, etc. Some of the library functions are printf, scanf, sqrt, etc. To use this functions in the program the user have to use associate header file associated to the corresponding function in the program.

For Example:

If, the user have to use print the data or scan the data using input stream then we have to use functions printf() and scanf() in C program and cin and cout in C++ program. To use these functions the user have to include #include<stdio.h> preprocesser directive in C program and #include<iostream> preprocesser directive in C++ program.

﹏﹏﹏﹏﹏✪✭✪﹏﹏﹏﹏﹏

// C program to illustrate inbuilt function

#include <stdio.h>

// Driver Code

int main()

{

// Print Statement

printf("GeeksforGeeks!");

return 0;

}

﹏﹏﹏﹏﹏✪✭✪﹏﹏﹏﹏﹏

User-defined function:

These functions are designed by the user when they are writing any program because for every task we do not have a library of functions where their definitions are predefined. To perform the according to the requirement of user the user have to develop some functions by itself, these functions are called user-defined functions. For such functions the user have to define the proper definition of the function.

For Example:

If we want to perform the addition of two numbers then below is the program to illustrate the addition of two numbers using

user-defined functions:

﹏﹏﹏﹏﹏✪✭✪﹏﹏﹏﹏﹏

// C program to illustrate user-defined function

#include <stdio.h>

// Function Call to find the sum of a and b

void findSum(int a, int b)

{

// Print the sum

printf("Sum is: %d", a + b);

}

// Driver Code

int main()

{

// Given two numbers

int a = 3, b = 5;

// Function Call

findSum(a, b);

return0

}

﹏﹏﹏﹏﹏✪✭✪﹏﹏﹏﹏﹏

HOPE IT HELPS UH ;)

Similar questions