Pointers Questions and Answers

Practice Mode
Showing 10 of 217 questions
Q71
The declaration float (*fp())(); is
  • A pointer fp returning float
  • B function fp returning a pointer to a function returning float
  • C function fp returning a pointer
  • D pointer to a function
Answer: Option B
Q72
When applied to a variable, what does the unary "&" opertor yield ?
  • A the variable's value
  • B the variable's address
  • C the variable's format
  • D the variable's right value
Answer: Option B
Q73
Which of the following is the most accurate statement about runtime memory ? 1. Memory is allocated by using malloc () 2. Memory is freed by a garbage collector 3. Allocated memory can be freed by calling free ( )
  • A option 1 only
  • B option 2 only
  • C both options 1 and 2
  • D both options 1 and 3
Answer: Option D
Q74
Which of the following is true about pointers ? 1. Pointers do not require memory storage. 2. The size of a pointer depends on the type of the variable it points to.
  • A option 1 only
  • B option 2 only
  • C options 1 and 2
  • D neither option 1 nor 2
Answer: Option D
Q75
Which of the following is True about pointers ? 1. Pointers do not require  memory storage. 2. The size of a pointer depends on the type f the variable it points to.
  • A option 1 only
  • B option 2 only
  • C options 1 and 2
  • D both options 1 and 3
Answer: Option D
Q76
If ptrl and ptr2 are valid pointers in the same array, then which of the following statements is valid ?
  • A ptrl + 2
  • B ptrl - ptr2
  • C ptrl * ptr2
  • D both options a and b
Answer: Option D
Q77
char *x; x = "AMMA"; is the above code valid ?
  • A Yes. A new memory space will be allocated to hold the string "AMMA".
  • B No. It would assign the string "AMMA" to an unallocated space in memory.
  • C Yes. The pointer x will point to the memory location created for the constant "AMMA".
  • D No. This sysntax is not allowed.
Answer: Option C
Q78
char *x = NULL; printf ("%s\n", x); What will be the behaviour o the sample code above ?
  • A This will not compile. A pointer cannot be initialized to NULL.
  • B The result will fall into "undefined behviour" and be unpredictable.
  • C A "0" will be printed
  • D Nothing will be printed.
Answer: Option B
Q79
char base [5] = "a" ; const char *ptr; Given the above, which of the following statements is legal ?
  • A ptr = base;
  • B *ptr =
  • C *ptr=base;
  • D ptr = 'a';
Answer: Option A
Q80
char *ptr; char string [ ] = "project"; ptr = string; ptr += (ptr + 5); What string does ptr contain in the sample code above ?
  • A ct
  • B ject
  • C oject
  • D Unknown. this code is incorrect
Answer: Option D
Questions and Answers for Competitive Exams Various Entrance Test