C-Pointers Question and Answer

C-Pointers Question and Answer
71. The declaration float (*fp())(); is
  • pointer fp returning float
  • function fp returning a pointer to a function returning float
  • function fp returning a pointer
  • pointer to a function
Show Answer
72. When applied to a variable, what does the unary "&" opertor yield ?
  • the variable's value
  • the variable's address
  • the variable's format
  • the variable's right value
Show Answer
73. 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 ( )
  • option 1 only
  • option 2 only
  • both options 1 and 2
  • both options 1 and 3
Show Answer
74. 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.
  • option 1 only
  • option 2 only
  • options 1 and 2
  • neither option 1 nor 2
Show Answer
75. 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.
  • option 1 only
  • option 2 only
  • options 1 and 2
  • both options 1 and 3
Show Answer
76. If ptrl and ptr2 are valid pointers in the same array, then which of the following statements is valid ?
  • ptrl + 2
  • ptrl - ptr2
  • ptrl * ptr2
  • both options a and b
Show Answer
77. char *x;
x = "AMMA";
is the above code valid ?
  • Yes. A new memory space will be allocated to hold the string "AMMA".
  • No. It would assign the string "AMMA" to an unallocated space in memory.
  • Yes. The pointer x will point to the memory location created for the constant "AMMA".
  • No. This sysntax is not allowed.
Show Answer
78. char *x = NULL;
printf ("%s\n", x);
What will be the behaviour o the sample code above ?
  • This will not compile. A pointer cannot be initialized to NULL.
  • The result will fall into "undefined behviour" and be unpredictable.
  • A "0" will be printed
  • Nothing will be printed.
Show Answer
79. char base [5] = "a" ;
const char *ptr;
Given the above, which of the following statements is legal ?
  • ptr = base;
  • *ptr =
  • *ptr=base;
  • ptr = 'a';
Show Answer
80. char *ptr;
char string [ ] = "project";
ptr = string;
ptr += (ptr + 5);
What string does ptr contain in the sample code above ?
  • ct
  • ject
  • oject
  • Unknown. this code is incorrect
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test