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

81. file *fpl, *fp2; fp1= fopen ("one", "w"); fp2=fopen("one", "w"); fputc ('a',fpl); fputc ('B'fp2); fclose (fp1); fclose(fp2); fp1=fopen("one", "r"); fp2=fopen("one", "r");  = getc (fp2); putchar (c); c = getc (fp1); putchar (c); What is the output of the above code ?

  • error
  • AB
  • BA
  • BB
Show Answer Report

82. What is the output o the following code ? # include <stdarg.h> show (int t, va_list ptrl) { int a,x,i; a=va arg (ptr1,int); printf("\n %d", a); } display (char *s, ...) { int x; va_list ptr; va_start (ptr, s); va_start (ptr,s); x=va_arg(ptr,int); show (x,ptr); } main() { display ("hello", 4, 12, 13, 14, 44) }

  • 13
  • 12
  • 44
  • 14
Show Answer Report

83. main (int x, char *y [ ] ) { printf ("%d %s", x, y [1]); } what is the output when the program is executed as prog arg1?

  • 1 prog
  • 1 arg1
  • 2 prog
  • 2 arg1
Show Answer Report

84. Study the following statements. #define DELAYTIME 1000 volatile extern int k; int j; for (i = 0; i <DELAYTIME;i++); j=k; State which one of the following is true.

  • volatile is meaningless for the variable k.
  • volatile is meaningful for the variable k since k is external and can change.
  • volatile is meaningless for the variable k since k is loop invariant.
  • none of the above.
Show Answer Report

85. Which ANSI C function can be used to obtain a date string from structure *tm?

  • sttime(tm)
  • asctime(tm)
  • gmtime(tm)
  • strtime(tm)
Show Answer Report

86. What is the output of the following program / enum mode {green, red orange, blue, white}; main () { green = green + 1; printf ("%d, %d", green, red); }

  • 1, 1
  • 0, 1
  • no, output, error in compilation
  • none of the above
Show Answer Report

87. What is the output of the following program ? # define  MAX(x, y) ((x) > (y) ? (x) : (y)) main () { int x = 5, y=5; printf ("maximum is %d", MAX (++x, ++y)); }

  • maximum is 7
  • maximum is 5
  • naxunyn is 6
  • none of the above
Show Answer Report

88. What is the value of  CAR in the following enumeration / enum transport { SCOOTER = 1, BUS=4, CAR, TRAIN=8 };

  • 0
  • 5
  • 7
  • 4
Show Answer Report

89. What is the value of LOTUS in the following enumeration ? enum symbol { HAND, SUN, LOTUS, UMBERLLA };

  • 0
  • 3
  • 2
  • none of the above
Show Answer Report

90. What is the output the following code ? enum fruits { APPLE = 1, ORANGE=1, GRAPES=3, PINEAPPLE }; printf ("%d",ORANGE);

  • Compilation error
  • Execution error
  • 2
  • 1
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test