C MCQ set number 00704

1. Which of the following causes an error?
a) Trying to read a file that doesn’t exist
b) Inability to write data in a file
c) Failure to allocate memory with the help of malloc
d) All of the mentioned

Answer

Answer: d [Reason:] None.

2. What is the purpose of the function?
    int ferror(FILE *fp)
a) They check for input errors
b) They check for output errors
c) They check for all types of errors
d) They check for error in accessing the file

Answer

Answer: b [Reason:] None.

3. stderr is similar to?
a) stdin
b) stdout
c) Both stdout and stdin
d) None of the mentioned

Answer

Answer: b [Reason:] stderr is not exactly same as stdout, but similar in the sense that both puts the output or error to the monitor

4. What happens when we use?
    fprintf(stderr, “error: could not open filen”);
a) The diagnostic output is directly displayed in the output
b) The diagnostic output is pipelined to the output file
c) The line which caused error is compiled again
d) The program is immediately aborted

Answer

Answer: a [Reason:] None.

5. Which of the following function can be used to terminate the main function from     another function safely?
a) return(expr);
b) exit(expr);
c) abort();
d) Both exit(expr); and abort();

Answer

Answer: b [Reason:] None.

6. Which of the following causes an error?
a) Trying to read a file that doesn’t exist
b) Inability to write data in a file.
c) Failure to allocate memory with the help of malloc
d) All of the menioned

Answer

Answer: d [Reason:] None.

7. What is the purpose of the function?
    int ferror(FILE *fp)
a) They check for input errors
b) They check for output errors
c) They check for all types of errors
d) They check for error in accessing the file

Answer

Answer: b [Reason:] None.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.