C - Files and Preprocessors Questions and Answers
C Files and Preprocessors Questions with Answers are essential for mastering file handling, macros, and directives in C programming. As part of programming questions and answers for placement exams, this topic helps students understand real-world input/output operations and code optimization techniques. Frequently asked in TCS, Wipro, and Capgemini tests, these questions assess how well you manage data files and preprocess instructions efficiently. Practicing these C programming MCQs with solutions improves your coding proficiency and exam accuracy. Access free C file handling and preprocessor aptitude questions with explanations in PDF or attempt our online mock test.
C - Files and Preprocessors
Showing 10 of
96 questions
52. Which of the following is valid for opening a read-only ASCII file ?
- fileopen (filenm, "read");
- fopen (filenm, "r");
- fileopen (filenm, "r");
- fopen (filenm, "read");
53. What are two predefined FILE pointers in C?
- stdout and stderr
- console and error
- stdout and stdio
- stdio and stderr
54. vaoid listfiele (FILE *f) { int C; while ( C = fgetc( f ) ! = EOF) { printf ("%d",c); } printf ("\n"); } What will be printed when the function above is called with pointer to an open file that contains the three characters abc ?
- The characters ab followed by an infinite number of c's
- 111
- abc
- 000
55. How could stderr be redirected from withing a program to force all error messages to be written to the end of the text file "error. log" instead of the location specified by the operating system ?
- stderr = fopen ( "error.log", "w");
- freopen ("error.log", "a", stderr);
- stderr = freopen (stderr, "a", "error.log");
- stderr = fopen ("errror.log", "a");
56. Which of the following would properly define a macro that doubled any expression passed to it ?
- # define DOUBLE (x ) x* 2
- # define DOUBLE (x) ((x)*);
- # define DOUBLE (x) (x) *2)
- # define DOUBLE (x) (x *2)
57. What will be the value of j in the following code ? # define CATCH (a) a + 1 int i = 2; int j = 4 * CATCH (I * 3);
- 24
- 25
- 28
- 32
58. Which of the following preprocessor directives will make the system-dependent constant INT_MAX available for an ANSI Ccompiler ?
- # include <limits.h>
- # include <int.h>
- # include <ctype.h>
- # define INT_MAX
59. Which of the following is NOT a pre-processor directive ?
- # if
- # line
- # elseif
- #pragma
60. Which of the following is NOT a pre-processor directive ?
- # elif
- # pragma
- # line
- #exclude