C Programming - Library Functions

Why C Programming Library Functions?

In this section you can learn and practice C Programming Questions based on "Library Functions" and improve your skills in order to face the interview, competitive examination and various entrance test (CAT, GATE, GRE, MAT, Bank Exam, Railway Exam etc.) with full confidence.

Where can I get C Programming Library Functions questions and answers with explanation?

IndiaBIX provides you lots of fully solved C Programming (Library Functions) questions and answers with Explanation. Solved examples with detailed answer description, explanation are given and it would be easy to understand. All students, freshers can download C Programming Library Functions quiz questions with answers as PDF files and eBooks.

Where can I get C Programming Library Functions Interview Questions and Answers (objective type, multiple choice)?

Here you can find objective type C Programming Library Functions questions and answers for interview and entrance examination. Multiple choice and true or false type questions are also provided.

How to solve C Programming Library Functions problems?

You can easily solve all kind of C Programming questions based on Library Functions by practicing the objective type exercises given below, also get shortcut methods to solve C Programming Library Functions problems.


What will the function rewind() do?

A. Reposition the file pointer to a character reverse.
B. Reposition the file pointer stream to end of file.
C. Reposition the file pointer to begining of that line.
D. Reposition the file pointer to begining of file.

Answer: Option D


rewind() takes the file pointer to the beginning of the file. so that the next I/O operation will take place at the beginning of the file.
Example: rewind(FilePointer);


Input/output function prototypes and macros are defined in which header file?

A. conio.h
B. stdlib.h
C. stdio.h
D. dos.h

Answer: Option C


stdio.h, which stands for "standard input/output header", is the header in the C standard library that contains macro definitions, constants, and declarations of functions and types used for various standard input and output operations.


Which standard library function will you use to find the last occurance of a character in a string in C?

A. strnchar()
B. strchar()
C. strrchar()
D. strrchr()

Answer: Option D


strrchr() returns a pointer to the last occurrence of character in a string.


#include <stdio.h>
#include <string.h>

int main()
    char str[30] = "12345678910111213";
    printf("The last position of '2' is %d.\n",
            strrchr(str, '2') - str);
    return 0;

Output: The last position of '2' is 14.


What is stderr ?

A. standard error
B. standard error types
C. standard error streams
D. standard error definitions

Answer: Option C


The standard error(stderr) stream is the default destination for error messages and other diagnostic warnings. Like stdout, it is usually also directed to the output device of the standard console (generally, the screen).


Does there any function exist to convert the int or float to a string?

A. Yes
B. No

Answer: Option A


1. itoa() converts an integer to a string.
2. ltoa() converts a long to a string.
3. ultoa() converts an unsigned long to a string.
4. sprintf() sends formatted output to a string, so it can be used to convert any type of values to string type.


int main(void)
   int   num1 = 12345;
   float num2 = 5.12;
   char str1[20];
   char str2[20];

   itoa(num1, str1, 10); /* 10 radix value */
   printf("integer = %d string = %s \n", num1, str1);

   sprintf(str2, "%f", num2);
   printf("float = %f string = %s", num2, str2);

   return 0;

// Output:
// integer = 12345 string = 12345
// float = 5.120000 string = 5.120000