C Programming Library Functions Online Test, C Programming Mock Test
C Programming Library Functions Online Test
Finish Quiz
0 of 29 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
Information
C Programming Library Functions Online Test. C Programming Question and Answers in English. C Programming Library Functions Online mock test paper is free for all students and Very Helpful for Exam Preparation. C Programming Library Functions Online Quiz. C Programming Online Mock test for Library Functions Topic. Here we are providing C Programming Library Functions Online Test Series in English. Check C Programming Mock Test Series 2019-2019.
This paper has 30 questions.
Time allowed is 30 minutes.
The C Programming online Mock Test Exam is Very helpful for all students. Now Scroll down below n click on “Start Quiz” or “Start Test” and Test yourself.
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 29 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
| Average score |  | 
| Your score |  | 
Categories
- Not categorized 0%
| Pos. | Name | Entered on | Points | Result | 
|---|---|---|---|---|
| Table is loading | ||||
| No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- Answered
- Review
- 
                            Question 1 of 291. QuestionWhat will the function rewind() do? Correct
 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);Incorrect
 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);
- 
                            Question 2 of 292. QuestionInput/output function prototypes and macros are defined in which header file? Correct
 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.Incorrect
 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.
- 
                            Question 3 of 293. QuestionWhich standard library function will you use to find the last occurance of a character in a string in C? Correct
 strrchr() returns a pointer to the last occurrence of character in a string. Example: #include#include 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. Incorrect
 strrchr() returns a pointer to the last occurrence of character in a string. Example: #include#include 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. 
- 
                            Question 4 of 294. QuestionWhat is stderr ? Correct
 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).Incorrect
 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).
- 
                            Question 5 of 295. QuestionDoes there any function exist to convert the int or float to a string? Correct
 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.#include#include 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 Incorrect
 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.#include#include 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 
- 
                            Question 6 of 296. QuestionWhat is the purpose of fflush() function. Correct
 “fflush()” flush any buffered output associated with filename, which is either a file opened for writing or a shell command for redirecting output to a pipe or coprocess. Example: 
 fflush(FilePointer);
 fflush(NULL); flushes all streams.Incorrect
 “fflush()” flush any buffered output associated with filename, which is either a file opened for writing or a shell command for redirecting output to a pipe or coprocess. Example: 
 fflush(FilePointer);
 fflush(NULL); flushes all streams.
- 
                            Question 7 of 297. QuestionCan you use the fprintf() to display the output on the screen? Correct
 Do like this fprintf(stdout, “%s %d %f”, str, i, a);Incorrect
 Do like this fprintf(stdout, “%s %d %f”, str, i, a);
- 
                            Question 8 of 298. QuestionWhat will the function randomize() do in Turbo C under DOS? Correct
 The randomize() function initializes the random number generator with a random value based on time. You can try the sample program given below in Turbo-C, it may not work as expected in other compilers. /* Prints a random number in the range 0 to 99 */ #include#include #include int main(void) { randomize(); printf("Random number in the 0-99 range: %d\n", random (100)); return 0; } Incorrect
 The randomize() function initializes the random number generator with a random value based on time. You can try the sample program given below in Turbo-C, it may not work as expected in other compilers. /* Prints a random number in the range 0 to 99 */ #include#include #include int main(void) { randomize(); printf("Random number in the 0-99 range: %d\n", random (100)); return 0; } 
- 
                            Question 9 of 299. QuestionWhat will be the output of the program? #includeint main() { int i; i = printf("How r u\n"); i = printf("%d\n", i); printf("%d\n", i); return 0; } Correct
 In the program, printf() returns the number of charecters printed on the console i = printf(“How r u\n”); This line prints “How r u” with a new line character and returns the length of string printed then assign it to variable i. 
 So i = 8 (length of ‘\n’ is 1).i = printf(“%d\n”, i); In the previous step the value of i is 8. So it prints “8” with a new line character and returns the length of string printed then assign it to variable i. So i = 2 (length of ‘\n’ is 1). printf(“%d\n”, i); In the previous step the value of i is 2. So it prints “2”. Incorrect
 In the program, printf() returns the number of charecters printed on the console i = printf(“How r u\n”); This line prints “How r u” with a new line character and returns the length of string printed then assign it to variable i. 
 So i = 8 (length of ‘\n’ is 1).i = printf(“%d\n”, i); In the previous step the value of i is 8. So it prints “8” with a new line character and returns the length of string printed then assign it to variable i. So i = 2 (length of ‘\n’ is 1). printf(“%d\n”, i); In the previous step the value of i is 2. So it prints “2”. 
- 
                            Question 10 of 2910. QuestionWhat will be the output of the program? #include#include int main() { float i = 2.5; printf("%f, %d", floor(i), ceil(i)); return 0; } Correct
 Both ceil() and floor() return the integer found as a double. floor(2.5) returns the largest integral value(round down) that is not greater than 2.5. So output is 2.000000. ceil(2.5) returns 3, while converting the double to int it returns ‘0’. 
 So, the output is ‘2.000000, 0’.Incorrect
 Both ceil() and floor() return the integer found as a double. floor(2.5) returns the largest integral value(round down) that is not greater than 2.5. So output is 2.000000. ceil(2.5) returns 3, while converting the double to int it returns ‘0’. 
 So, the output is ‘2.000000, 0’.
- 
                            Question 11 of 2911. QuestionWhat will be the output of the program? #includeint main() { int i; i = scanf("%d %d", &i, &i); printf("%d\n", i); return 0; } Correct
 scanf() returns the number of variables to which you are provding the input. i = scanf(“%d %d”, &i, &i); Here Scanf() returns 2. So i = 2. printf(“%d\n”, i); Here it prints 2. Incorrect
 scanf() returns the number of variables to which you are provding the input. i = scanf(“%d %d”, &i, &i); Here Scanf() returns 2. So i = 2. printf(“%d\n”, i); Here it prints 2. 
- 
                            Question 12 of 2912. QuestionWhat will be the output of the program? #includeint main() { int i; char c; for(i=1; i5; i++) { scanf("%c", &c); /* given input is 'b' */ ungetc(c, stdout); printf("%c", c); ungetc(c, stdin); } return 0; } Correct
 The ungetc() function pushes the character c back onto the named input stream, which must be open for reading. This character will be returned on the next call to getc or fread for that stream. One character can be pushed back in all situations. A second call to ungetc without a call to getc will force the previous character to be forgotten. Incorrect
 The ungetc() function pushes the character c back onto the named input stream, which must be open for reading. This character will be returned on the next call to getc or fread for that stream. One character can be pushed back in all situations. A second call to ungetc without a call to getc will force the previous character to be forgotten. 
- 
                            Question 13 of 2913. QuestionWhat will be the output of the program? #include#include int main() { char *i = "55.555"; int result1 = 10; float result2 = 11.111; result1 = result1+atoi(i); result2 = result2+atof(i); printf("%d, %f", result1, result2); return 0; } Correct
 Function atoi() converts the string to integer. 
 Function atof() converts the string to float.result1 = result1+atoi(i); 
 Here result1 = 10 + atoi(55.555);
 result1 = 10 + 55;
 result1 = 65;result2 = result2+atof(i); 
 Here result2 = 11.111 + atof(55.555);
 result2 = 11.111 + 55.555000;
 result2 = 66.666000;
 So the output is “65, 66.666000” .Incorrect
 Function atoi() converts the string to integer. 
 Function atof() converts the string to float.result1 = result1+atoi(i); 
 Here result1 = 10 + atoi(55.555);
 result1 = 10 + 55;
 result1 = 65;result2 = result2+atof(i); 
 Here result2 = 11.111 + atof(55.555);
 result2 = 11.111 + 55.555000;
 result2 = 66.666000;
 So the output is “65, 66.666000” .
- 
                            Question 14 of 2914. QuestionWhat will be the output of the program? #include#include int main() { char dest[] = {97, 97, 0}; char src[] = "aaa"; int i; if((i = memcmp(dest, src, 2))==0) printf("Got it"); else printf("Missed"); return 0; } Correct
 memcmp compares the first 2 bytes of the blocks dest and src as unsigned chars. So, the ASCII value of 97 is ‘a’. if((i = memcmp(dest, src, 2))==0) When comparing the array dest and src as unsigned chars, the first 2 bytes are same in both variables.so memcmp returns ‘0’. 
 Then, the if(0=0) condition is satisfied. Hence the output is “Got it”.Incorrect
 memcmp compares the first 2 bytes of the blocks dest and src as unsigned chars. So, the ASCII value of 97 is ‘a’. if((i = memcmp(dest, src, 2))==0) When comparing the array dest and src as unsigned chars, the first 2 bytes are same in both variables.so memcmp returns ‘0’. 
 Then, the if(0=0) condition is satisfied. Hence the output is “Got it”.
- 
                            Question 15 of 2915. QuestionWhat will function gcvt() do? Correct
 The gcvt() function converts a floating-point number to a string. It converts given value to a null-terminated string. #include#include int main(void) { char str[25]; double num; int sig = 5; /* significant digits */ /* a regular number */ num = 9.876; gcvt(num, sig, str); printf("string = %s\n", str); /* a negative number */ num = -123.4567; gcvt(num, sig, str); printf("string = %s\n", str); /* scientific notation */ num = 0.678e5; gcvt(num, sig, str); printf("string = %s\n", str); return(0); } Output: 
 string = 9.876
 string = -123.46
 string = 67800Incorrect
 The gcvt() function converts a floating-point number to a string. It converts given value to a null-terminated string. #include#include int main(void) { char str[25]; double num; int sig = 5; /* significant digits */ /* a regular number */ num = 9.876; gcvt(num, sig, str); printf("string = %s\n", str); /* a negative number */ num = -123.4567; gcvt(num, sig, str); printf("string = %s\n", str); /* scientific notation */ num = 0.678e5; gcvt(num, sig, str); printf("string = %s\n", str); return(0); } Output: 
 string = 9.876
 string = -123.46
 string = 67800
- 
                            Question 16 of 2916. QuestionWhat will be the output of the program? #includeint main() { int i; char c; for(i=1; i5; i++) { scanf("%c", &c); /* given input is 'a' */ printf("%c", c); ungetc(c, stdin); } return 0; } Correct
 for(i=1; i Here the for loop runs 5 times. Loop 1: 
 scanf(“%c”, &c); Here we give ‘a’ as input.
 printf(“%c”, c); prints the character ‘a’ which is given in the previous “scanf()” statement.
 ungetc(c, stdin); “ungetc()” function pushes character ‘a’ back into input stream.Loop 2: 
 Here the scanf(“%c”, &c); get the input from “stdin” because of “ungetc” function.
 printf(“%c”, c); Now variable c = ‘a’. So it prints the character ‘a’.
 ungetc(c, stdin); “ungetc()” function pushes character ‘a’ back into input stream.This above process will be repeated in Loop 3, Loop 4, Loop 5. Incorrect
 for(i=1; i Here the for loop runs 5 times. Loop 1: 
 scanf(“%c”, &c); Here we give ‘a’ as input.
 printf(“%c”, c); prints the character ‘a’ which is given in the previous “scanf()” statement.
 ungetc(c, stdin); “ungetc()” function pushes character ‘a’ back into input stream.Loop 2: 
 Here the scanf(“%c”, &c); get the input from “stdin” because of “ungetc” function.
 printf(“%c”, c); Now variable c = ‘a’. So it prints the character ‘a’.
 ungetc(c, stdin); “ungetc()” function pushes character ‘a’ back into input stream.This above process will be repeated in Loop 3, Loop 4, Loop 5. 
- 
                            Question 17 of 2917. QuestionPoint out the error in the following program. #includeint main() { fprintf("IndiaBIX"); printf("%.ef", 2.0); return 0; } Correct
 Declaration Syntax: 
 int fprintf (FILE *stream, const char *format [, argument, …]);Example: 
 fprintf(filestream, “%s %d %s”, Name, Age, City);Incorrect
 Declaration Syntax: 
 int fprintf (FILE *stream, const char *format [, argument, …]);Example: 
 fprintf(filestream, “%s %d %s”, Name, Age, City);
- 
                            Question 18 of 2918. QuestionPoint out the error in the following program. #include#include int main() { char str1[] = "Learn through IndiaBIX\0.com", str2[120]; char *p; p = (char*) memccpy(str2, str1, 'i', strlen(str1)); *p = '\0'; printf("%s", str2); return 0; } Correct
 Declaration: 
 void *memccpy(void *dest, const void *src, int c, size_t n); : Copies a block of n bytes from src to destWith memccpy(), the copying stops as soon as either of the following occurs: 
 => the character ‘i’ is first copied into str2
 => n bytes have been copied into str2Incorrect
 Declaration: 
 void *memccpy(void *dest, const void *src, int c, size_t n); : Copies a block of n bytes from src to destWith memccpy(), the copying stops as soon as either of the following occurs: 
 => the character ‘i’ is first copied into str2
 => n bytes have been copied into str2
- 
                            Question 19 of 2919. QuestionPoint out the error in the following program. #includeint main() { char str[] = "IndiaBIX"; printf("%.#s %2s", str, str); return 0; } Correct
 Incorrect
 
- 
                            Question 20 of 2920. QuestionIt is necessary that for the string functions to work safely the strings must be terminated with ‘\0’. Correct
 C string is a character sequence stored as a one-dimensional character array and terminated with a null character(‘\0’, called NULL in ASCII). 
 The length of a C string is found by searching for the (first) NULL byte.Incorrect
 C string is a character sequence stored as a one-dimensional character array and terminated with a null character(‘\0’, called NULL in ASCII). 
 The length of a C string is found by searching for the (first) NULL byte.
- 
                            Question 21 of 2921. QuestionFILE is a structure suitably typedef‘d in “stdio.h”. Correct
 FILE – a structure containing the information about a file or text stream needed to perform input or output operations on it, including: 
 => a file descriptor, the current stream position,
 => an end-of-file indicator,
 => an error indicator,
 => a pointer to the stream’s buffer, if applicablefpos_t – a non-array type capable of uniquely identifying the position of every byte in a file. 
 size_t – an unsigned integer type which is the type of the result of the sizeof operator.Incorrect
 FILE – a structure containing the information about a file or text stream needed to perform input or output operations on it, including: 
 => a file descriptor, the current stream position,
 => an end-of-file indicator,
 => an error indicator,
 => a pointer to the stream’s buffer, if applicablefpos_t – a non-array type capable of uniquely identifying the position of every byte in a file. 
 size_t – an unsigned integer type which is the type of the result of the sizeof operator.
- 
                            Question 22 of 2922. Questionftell() returns the current position of the pointer in a file stream. Correct
 The ftell() function shall obtain the current value of the file-position indicator for the stream pointed to by stream. Example: #includeint main(void) { FILE *stream; stream = fopen("MYFILE.TXT", "w+"); fprintf(stream, "This is a test"); printf("The file pointer is at byte %ld\n", ftell(stream)); fclose(stream); return 0; } Incorrect
 The ftell() function shall obtain the current value of the file-position indicator for the stream pointed to by stream. Example: #includeint main(void) { FILE *stream; stream = fopen("MYFILE.TXT", "w+"); fprintf(stream, "This is a test"); printf("The file pointer is at byte %ld\n", ftell(stream)); fclose(stream); return 0; } 
- 
                            Question 23 of 2923. QuestionData written into a file using fwrite() can be read back using fscanf() Correct
 fwrite() – Unformatted write in to a file. 
 fscanf() – Formatted read from a file.Incorrect
 fwrite() – Unformatted write in to a file. 
 fscanf() – Formatted read from a file.
- 
                            Question 24 of 2924. QuestionIf the two strings are found to be unequal then strcmp returns difference between the first non-matching pair of characters. Correct
 g = strcmp(s1, s2); returns 0 when the strings are equal, a negative integer when s1 is less than s2, or a positive integer if s1 is greater than s2, that strcmp() not only returns -1, 0 and +1, but also other negative or positive values(returns difference between the first non-matching pair of characters between s1 and s2). A possible implementation for strcmp() in “The Standard C Library”. int strcmp (const char * s1, const char * s2) { for(; *s1 == *s2; ++s1, ++s2) { if(*s1 == 0) return 0; } return *(unsigned char *)s1 unsigned char *)s2 ? -1 : 1; }Incorrect
 g = strcmp(s1, s2); returns 0 when the strings are equal, a negative integer when s1 is less than s2, or a positive integer if s1 is greater than s2, that strcmp() not only returns -1, 0 and +1, but also other negative or positive values(returns difference between the first non-matching pair of characters between s1 and s2). A possible implementation for strcmp() in “The Standard C Library”. int strcmp (const char * s1, const char * s2) { for(; *s1 == *s2; ++s1, ++s2) { if(*s1 == 0) return 0; } return *(unsigned char *)s1 unsigned char *)s2 ? -1 : 1; }
- 
                            Question 25 of 2925. QuestionIs standard library a part of C language? Correct
 The C standard library consists of a set of sections of the ISO C standard which describe a collection of header files and library routines used to implement common operations, such as input/output and string handling, in the C programming language. The C standard library is an interface standard described by a document; it is not an actual library of software routines available for linkage to C programs. Incorrect
 The C standard library consists of a set of sections of the ISO C standard which describe a collection of header files and library routines used to implement common operations, such as input/output and string handling, in the C programming language. The C standard library is an interface standard described by a document; it is not an actual library of software routines available for linkage to C programs. 
- 
                            Question 26 of 2926. QuestionWill the program outputs “IndiaBIX.com”? #include#include int main() { char str1[] = "IndiaBIX.com"; char str2[20]; strncpy(str2, str1, 8); printf("%s", str2); return 0; } Correct
 No. It will print something like ‘IndiaBIX(some garbage values here)’ . Because after copying the first 8 characters of source string into target string strncpy() doesn’t terminate the target string with a ‘\0’. So it may print some garbage values along with IndiaBIX. Incorrect
 No. It will print something like ‘IndiaBIX(some garbage values here)’ . Because after copying the first 8 characters of source string into target string strncpy() doesn’t terminate the target string with a ‘\0’. So it may print some garbage values along with IndiaBIX. 
- 
                            Question 27 of 2927. QuestionThe itoa function can convert an integer in decimal, octal or hexadecimal form to a string. Correct
 itoa() takes the integer input value input and converts it to a number in base radix. The resulting number a sequence of base-radix digits. Example: /* itoa() example */ #include#include int main () { int no; char buff [50]; printf ("Enter number: "); scanf ("%d",&no); itoa (no,buff,10); printf ("Decimal: %s\n",buff); itoa (no,buff,2); printf ("Binary: %s\n",buff); itoa (no,buff,16); printf ("Hexadecimal: %s\n",buff); return 0; } Output: 
 Enter a number: 1250
 Decimal: 1250
 Binary: 10011100010
 Hexadecimal: 4e2Incorrect
 itoa() takes the integer input value input and converts it to a number in base radix. The resulting number a sequence of base-radix digits. Example: /* itoa() example */ #include#include int main () { int no; char buff [50]; printf ("Enter number: "); scanf ("%d",&no); itoa (no,buff,10); printf ("Decimal: %s\n",buff); itoa (no,buff,2); printf ("Binary: %s\n",buff); itoa (no,buff,16); printf ("Hexadecimal: %s\n",buff); return 0; } Output: 
 Enter a number: 1250
 Decimal: 1250
 Binary: 10011100010
 Hexadecimal: 4e2
- 
                            Question 28 of 2928. QuestionThe prototypes of all standard library string functions are declared in the file string.h. Correct
 string.h is the header in the C standard library for the C programming language which contains macro definitions, constants, and declarations of functions and types used not only for string handling but also various memory handling functions.Incorrect
 string.h is the header in the C standard library for the C programming language which contains macro definitions, constants, and declarations of functions and types used not only for string handling but also various memory handling functions.
- 
                            Question 29 of 2929. Questionscanf() or atoi() function can be used to convert a string like “436” in to integer. Correct
 scanf is a function that reads data with specified format from a given string stream source. 
 scanf(“%d”,&number);atoi() convert string to integer. 
 var number;
 number = atoi(“string”);Incorrect
 scanf is a function that reads data with specified format from a given string stream source. 
 scanf(“%d”,&number);atoi() convert string to integer. 
 var number;
 number = atoi(“string”);
