RejinpaulPlacement
Search

Library Functions - C Programming Questions and Answers - RejinpaulPlacement

@ : Home > C Programming > Library Functions


Find us on Facebook



Follow us on Google+


Google+

1.
What will the function randomize() do in Turbo C under DOS?
Answer & Solution
Answer: (C) returns a random number generator with a random value based on time.
Solution:
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;
}
close
2.
Does there any function exist to convert the int or float to a string?
Answer & Solution
Answer: (A) Yes
Solution:
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.
close
3.
What is the purpose of fflush() function.
Answer & Solution
Answer: (A) flushes all streams and specified streams.
Solution:
"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. close
4.
What will the function rewind() do?

Answer & Solution
Answer:
(D) Reposition the file pointer to begining of file.
Solution: 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);
close
5.
Input/output function prototypes and macros are defined in which header file?

Answer & Solution
Answer: (C) stdio.h
Solution:
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.
close