C Programming - Library Functions

6.
What is the purpose of fflush() function.
flushes all streams and specified streams.
flushes only specified stream.
flushes input/output buffer.
flushes file buffer.
Answer: Option
Explanation:
"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.


7.
Can you use the fprintf() to display the output on the screen?
Yes
No
Answer: Option
Explanation:
Do like this fprintf(stdout, "%s %d %f", str, i, a);

8.
What will the function randomize() do in Turbo C under DOS?
returns a random number.
returns a random number generator in the specified range.
returns a random number generator with a random value based on time.
return a random number with a given seed value.
Answer: Option
Explanation:

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 <stdlib.h>
#include <stdio.h>
#include <time.h>

int main(void)
{
    randomize();
    printf("Random number in the 0-99 range: %d\n", random (100));
    return 0;
}