Library Functions Class 12 Computer Notes and Questions

Notes Class 12 Revision Notes

Please refer to Library Functions Class 12 Computer notes and questions with solutions below. These revision notes and important examination questions have been prepared based on the latest Computer Science books for Class 12. You can go through the questions and solutions below which will help you to get better marks in your examinations.

Class 12 Computer Library Functions Notes and Questions

Fill in the blanks

Question 1__________ is a self-contained block of statements that perform a specific task.

Answer

Function

Question 2 Functions can be broadly classified broadly in ____________ categories.

Answer

two

Question 3 ___________ function converts the character type in argument to lower case

Answer

. tolower()

Question 4 Library functions that carry out standard input/output operations are included in __________ header file

Answer

stdio.h

Question 5 All library functions available are grouped under __________ file.

Answer

header

Library Functions Class 12 Computer Short answer type Questions

Questions 1 Functions can be classified into how many types?
Ans: Functions can be classified mainly into two categories:
Library or Built-in functions: Those functions, which are in-built or predefined in the C language, are called standard or library functions. All these functions are organized in header files (also called library files). To use any library function, we must include the corresponding header file (in which it is defined) in our program. For example: clrscr( ), printf(), scanf(), sqrt(), strcpy() etc. are the predefined functions.

Class 12 Computer Library Functions Notes and Questions

User defined functions: Those functions, which are defined by the user, are called user defined functions. User can
define his own functions to fulfil his requirements. The function main() is an example of user defined function. Its
body is defined by user.

Question 2 Explain library function?
Ans: Those functions, which are in-built or pre-defined in the C language, are called standard or library functions. All
these functions are organized in header files (also called library files). To use any library function, we must include
the corresponding header file (in which it is defined) in our program. For example: clrscr( ), printf(), scanf(), sqrt(),
strcpy() etc. are the predefined functions. The input output functions scanf( ) and printf( ) are defined in the stdio.h
header file. So, we have to include this file in our program if we want to use these functions. Similarly, string
functions strlen( ), strcpy( ), strcat( ), strcmp( ), strupr( ), strlwr( ) etc. are defined in the string.h header file. So, we
must include string.h header file to use these string functions in our program.

Question 3 Which files are included at the beginning of program and why?
Ans: Header files are included at the beginning of program. Extension of these files is .h. Library functions are logical
grouped into header files. To use any library function, we have to include corresponding header files in which they
are defined. That is why these header files are included at the beginning of the program. Some of the commonly
used header files are: stdio.h, conio.h, math.h, string.h etc.

Question 4 Explain difference between user-defined and library function?
Ans: The difference between user-defined and library functions are given below:
Library or Built-in functions: Those functions, which are in-built or pre-defined in the C language, are called standard
or library functions. All these functions are organized in header files (also called library files). To use any library
function, we must include the corresponding header file (in which it is defined) in our program. For example: clrscr(),
printf(), scanf(), sqrt(), strcpy() etc. are the predefined functions.
User defined functions: Those functions, which are defined by the user, are called user defined functions. User can
define his own functions to fulfil his requirements. The function main() is an example of user defined function. Its
body is defined by user.

Question 5 Give the names of library functions included in string.h file?
Ans: all the string handling functions has been defined in the string.h header file. Some of the commonly used string
functions are given below:
strlen() function
strcmp() function
strcat() function
strcpy() function
strrev) function
strupr() function
strlwr() function

Question 6 Give the names of any four header files used in C?
Ans: Commonly used header files used in C along with their library functions are given below:
i. Header file – stdio.h: Full form of stdio is Standard Input Output. This header file contains the functions that are
used for Standard Input and Output operations. For example: printf(), scanf() functions
ii. Header file – ctype.h: This header file contains functions that are used to perform operations on character data.
For example: tolower(), toupper(), islower(), isupper() etc.
iii. Header file – string.h: This header file contains functions that are used to perform operations on string data. For
example: strlen(), strupr(), strlwr(), strcat(), strcmp() etc.
iv. Header file – math.h: This header file contains functions that are used to perform mathematical operations. For
example: sqrt(), pow(), sin(), cos() etc.

Question 7 Explain strcpy function with example?
Ans: Function strcpy stands for string copy. This function is used to copy a string value into string variable. Following
code shows how to use this function. This function is present in the string.h header file. Therefore, to use this
function, we have to include the string.h header file in our program.
strcpy(str, “Punjab”);
It copy/store the string value “Punjab” into the string variable str.

Question 8 Write a program in C using tolower function?
Ans: The functions tolower() is used to convert the character value into the lower case. Consider the following
example program:
#include<stdio,h>
#include<stdio,h>
#include<stdio,h>
void main()
{
char value;
value=tolower(‘A’);
printf(“%c”,value); //shows a
}

Question 9 Write a program in C using strcat function?
Ans: The function strcat is used to concatenate (combine) two string values. Consider the following example
program:
#include<stdio,h>
#include<stdio,h>
void main()
{
char value1[20]=”Hello”;
char value2[20]=”Students”
strcat(value1,value2);
printf(“%s”,value1); //shows Hello Students
}

Long answer Type Questions

Question 1 What are the main advantages of functions?
Ans: (see Chapter 3rd)

Question 2 Describe library functions? Explain any four in detail.
Ans: Those functions, which are in-built or pre-defined in the C language, are called standard or library functions. All
these functions are organized in header files (also called library files). To use any library function, we must include
the corresponding header file (in which it is defined) in our program. For example: clrscr( ), printf(), scanf(), sqrt(),
strcpy() etc. are the predefined functions. Four library functions are explained below:
Function strcpy():Function strcpy stands for string copy. This function is used to copy a string value into string
variable. This function is present in the string.h header file. Therefore, to use this function, we have to include the
string.h header file in our program. Following code shows how to use this function.
strcpy(str, “Punjab”); //copy Punjab into str
Function strlen():Function strlen() stands for string length. This function is used to count the total number of
characters in the given string. This function is present in the string.h header file. Following code shows how to use
this function:
strlen(“punjab”); //returns 6
Function sqrt (): Sqrt stands for square rootFunction. It is a mathematical function. It returns the square root of the
gven value. This function is present in the math.h header file. Following code shows how to use this function:
sqrt(36); //returns 6.0
Function toupper(): This function is used to convert the given character value to upper case. Thisfunction is
present in the ctype.h header file. Following code shows how to use this function:
toupper(‘a’); //returns A

Question 3 Write a program to calculate square root of a number using library function.
Ans: The function sqrt() is used to calculate the square root of number. This function is present in the math.h header
file. Following program shows how to use this function:
#include<stdio,h>
#include<stdio,h>
void main() {
float result;
result=sqrt(9);
printf(“%f”,result); //shows 3.000000
}

Question 4 Write a Program which accept a Character and convert it into upper case.
Ans: The function toupper() is used to convert a character into upper case. This function is present in the ctype.h
headerfile. Following program shows how to use this function:
#include<stdio,h>
#include<stdio,h>
void main()
{
char value;
value=toupper(‘a’);
printf(“%c”,value); //shows A

Question 5 Write a program to calculate the length of following string: “satik”
Ans: The function strlen() is used to calculate the length of a string. This function is present in the string.h header file.
Following program shows how to use this function:
#include<stdio,h>
#include<stdio,h>
void main() {
int length;
length=strlen(“Satik”);
printf(“%d”,length); //shows 5
}

Question 6 Write a program to find the sum of following series: H = x2 + x4 + x6 + ………………+xn
Ans:

Class 12 Computer Library Functions Notes and Questions
Library Functions Class 12 Computer

We hope the above Library Functions Class 12 Computer are useful for you. If you have any questions then post them in the comments section below. Our teachers will provide you an answer. Also refer to MCQ Questions for Class 12 Computer Science