/* */ Click to Join Live Class with Shankar sir Call 9798158723

C pointer MCQ


Q1. What is the base data type of a pointer variable by which the memory would be allocated to it?
  1. int
  2. float
  3. No datatype
  4. Depends upon the type of the variable to which it is pointin
  5. unsigned int

Answer:- (E).
Explanations :None
Q2. Prior to using a pointer variable it should be
  1. Declared
  2. Initialized
  3. Both declared and initalized
  4. None of these

Answer:- (C).
Explanations :Using a pointer variable, without initializing it, will be disastrous, as it will have a garbage value.
Q3. In C a pointer variable to an integer can be created by the decalaration
  1. int p*;
  2. int *p;
  3. int +p;
  4. int $p;

Answer:- (B).
Explanations :None.
Q4. A pointer variable can be
  1. Passed to a function
  2. Changed within a function
  3. Returned by a function
  4. Can be assigned an integer value

Answer:- (C).
Explanations :None.
Q5. What will be the output of the following C code?
void main() {
  int a[] = {1,2,3,4,5}, *p;
  p = a;
  ++*p;
  printf("%d ", *p);
p += 2;
  printf("%d ", *p);
}
  1. 24
  2. 34
  3. 22
  4. 23

Answer:- (BB).
Explanations :none.
Q6. What is the output of the following C code?
  char *ptr;
  char mystring[] = "abcdefg";
  ptr = myString;
  ptr += 5;
  1. fg
  2. efg
  3. defg
  4. bcdefg

Answer:- (A).
Explanations :none.
Q7. Will this program compile?
int main() {
  char str[5] = "LetsFind";
  return 0;
}
  1. True
  2. False

Answer:- (A).
Explanations :C doesn't do array bounds checking at compile time, hence this compiles.But, the modern compilers like Turbo C++ detects this as 'Error: Too many initializers'.GCC would give you a warning.
Q8. Is the NULL pointer same as an uninitialised pointer?
  1. Truer
  2. Falser

Answer:- (B).
Explanations :none.
Q9. Which of the following statements correct about k used in the below statement?
char ****k;
  1. k is a pointer to a pointer to a pointer to a char
  2. k is a pointer to a pointer to a pointer to a pointer to a char
  3. k is a pointer to a char pointer
  4. k is a pointer to a pointer to a char

Answer:- (B).
Explanations :k is a pointer to a pointer to a pointer to a pointer to a char.
Q10. What will be the output of the program.
char *p = 0;
char *t = NULL;
  1. Yes
  2. No

Answer:- (B).
Explanations :NULL is #defined as 0 in the 'stdio.h' file. Thus, both p and t are NULL pointers.