C - Files and Preprocessors Questions and Answers

Take Exam

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

51. Identify the trigraph sequence for ^.

  • ??/
  • ??=
  • ??'
  • ??!
Show Answer Report

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");
Show Answer Report

53. What are two predefined FILE pointers in C?

  • stdout and stderr
  • console and error
  • stdout and stdio
  • stdio and stderr
Show Answer Report

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
Show Answer Report

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");
Show Answer Report

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)
Show Answer Report

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
Show Answer Report

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
Show Answer Report

59. Which of the following is NOT a pre-processor directive ?

  • # if
  • # line
  • # elseif
  • #pragma
Show Answer Report

60. Which of the following is NOT a pre-processor directive ?

  • # elif
  • # pragma
  • # line
  • #exclude
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test