C-Pointers Question and Answer

C-Pointers Question and Answer
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
Show Answer
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)
Show Answer
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
Show Answer
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
Show Answer
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
Show Answer
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
Show Answer
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 ); }
Show Answer
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
Show Answer
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
Show Answer
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
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test