Pointers Questions and Answers
Pointers questions with answers are a crucial part of C programming preparation, often included in technical interviews and MCQ-based exams. Pointers are variables that store the memory address of other variables, making them fundamental to dynamic memory management and efficient program design. These C programming MCQ questions and answers help students understand pointer arithmetic, function pointers, arrays, and memory allocation. Commonly asked in placement exams by TCS, Infosys, and Wipro, mastering pointer concepts gives you a competitive edge in coding tests and programming interviews.
Pointers
Showing 10 of
217 questions
111. void display (int *list) {printf ("element = %d\n", *(list + 3)); } int main ( ) { int ary [3] [3] = {{0}, {2, 3}, {4, 5, 6}}; display ((int *) ary); return 0; } What will be printed when the sample code above is executed ?
- element = 0
- element = 2
- element = 3
- element = 4
112. #include <math.h> static double (*funcs [] ) ( double ) = { sin, cos, tan, asin, acos, atan, sinh, cosh, tanh }; double compute Trig Function (int index, double argument) { return ????; } Referring to the sample code above, which should compute the value of a trigonometric function based on its index, what would be a replacement for the ???? to make the correct call ?
- (*funcs) [ index ] (argument)
- funcs [index] (argument)
- funcs (argument) [index]
- *funcs [index] (argument)
113. float (*f[5]()); This declaration represents
- pointer to function returning array of float
- pointer to array of pointer to function returning float
- array of pointers to function returning array of float
- array of pointers to function returning float
114. float (*f( ) ) [5]; This declaration represents
- function returningg a pointer to the array of float
- pointer to function returning array of float
- array to function returning float
- all of the above
115. char (*(*f()[]) (); This pointer declaration represents
- function returning array of pointer to a function
- pointer to array of pointer to a function return char
- function returning a pointer to array of pointer to a function returning char
- function returning a pointer to returning char
116. float (*(*[5])()[10]; This declaration represents
- array [5] of function returning a pointer to array [10]of float
- array of pointer returning pointer to array [10] of float
- array [5] of pointer to a function returning a pointer to array [10] of float
- none
117. # include <stdio.h> char *format = "%d"; int main ( ) { int x; void func ( ) ; func ( scanf, &X ); printf ("%D\n", x ); return 0; } Referring to the sample code above, which of the following would be a correct implementation for func ?
- void func ( int *y (const char*, ... ), int *x ) { (*y) ( format, &x) ; }
- void func ( int (*y) const char*, ...), int*x) { (*y) (format , x); }
- void func ( int (*y) (const char *, ...), int *x) { (*y) (format, &X ); }
- void func ( ( int *) y (const char *, ... ), int *x) {(*y) (format, x ); }
118. In the declaration int x[3][2][2] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; *(*(*(x+2) +1) +1) represents
- the element 13
- the element 9
- the address of the element of 8
- the address of the element of 9
119. int a = 1; b = 2; c = 3; *pointer; pointer = &c; a = c/*pointer; b = c; printf ("a=%d b=%d", a,b); What will be the output?
- a=1 b=3
- a=3 b=3
- 3 2
- Error
120. void fn (int *a, int *b) { int *t; t=a; a = b; b=t; } main ( ) { int a = 2; void fn ( ); int b=3; fn (&a, &b); printf ("%d %d\n", a, b); } What will be the output ?
- Error at runtime
- Compilation error
- 2 3
- 3 2