C - Files and Preprocessors Questions and Answers

Practice Mode
Showing 10 of 96 questions
Q81
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 ?
  • A error
  • B AB
  • C BA
  • D BB
Answer: Option D
Q82
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) }
  • A 13
  • B 12
  • C 44
  • D 14
Answer: Option B
Q83
main (int x, char *y [ ] ) { printf ("%d %s", x, y [1]); } what is the output when the program is executed as prog arg1?
  • A 1 prog
  • B 1 arg1
  • C 2 prog
  • D 2 arg1
Answer: Option D
Q84
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.
  • A volatile is meaningless for the variable k.
  • B volatile is meaningful for the variable k since k is external and can change.
  • C volatile is meaningless for the variable k since k is loop invariant.
  • D none of the above.
Answer: Option B
Q85
Which ANSI C function can be used to obtain a date string from structure *tm?
  • A sttime(tm)
  • B asctime(tm)
  • C gmtime(tm)
  • D strtime(tm)
Answer: Option B
Q86
What is the output of the following program / enum mode {green, red orange, blue, white}; main () { green = green + 1; printf ("%d, %d", green, red); }
  • A 1, 1
  • B 0, 1
  • C no, output, error in compilation
  • D none of the above
Answer: Option C
Q87
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)); }
  • A maximum is 7
  • B maximum is 5
  • C naxunyn is 6
  • D none of the above
Answer: Option A
Q88
What is the value of  CAR in the following enumeration / enum transport { SCOOTER = 1, BUS=4, CAR, TRAIN=8 };
  • A 0
  • B 5
  • C 7
  • D 4
Answer: Option B
Q89
What is the value of LOTUS in the following enumeration ? enum symbol { HAND, SUN, LOTUS, UMBERLLA };
  • A 0
  • B 3
  • C 2
  • D none of the above
Answer: Option C
Q90
What is the output the following code ? enum fruits { APPLE = 1, ORANGE=1, GRAPES=3, PINEAPPLE }; printf ("%d",ORANGE);
  • A Compilation error
  • B Execution error
  • C 2
  • D 1
Answer: Option D
Questions and Answers for Competitive Exams Various Entrance Test