Loading...

C Multiple Choice Questions

Our C questions and answers focuses on all areas of C programming language covering 100+ topics in C

C Pointers-3 MCQs

C Pointers-3


1. What is the base data type of a pointer variable by which the memory would be allocated to it?

a) int
b) float
c) No datatype
d) Depends upon the type of the variable to which it is pointing
e) unsigned int



2. Prior to using a pointer variable it should be

a) Declared
b) Initialized
c) Both declared and initalized
d) None of these



3. In C a pointer variable to an integer can be created by the decalaration

a) int p*;
b) int *p;
c) int +p;
d) int $p;



4. A pointer variable can be

a) Passed to a function
b) Changed within a function
c) Returned by a function
d) Can be assigned an integer value



5. 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);
}

a) 24
b) 34
c) 22
d) 23



6. What is the output of the following C code?
  char *ptr;
  char mystring[] = "abcdefg";
  ptr = myString;
  ptr += 5;

a) fg b) efg c) defg d) cdefg e) bcdefg



7. Will this program compile?
int main() {
  char str[5] = "LetsFind";
  return 0;
}

a) True
b) False



8. Is the NULL pointer same as an uninitialised pointer?

a) True
b) False



9. Which of the following statements correct about k used in the below statement?
char ****k;

a) k is a pointer to a pointer to a pointer to a char
b) k is a pointer to a pointer to a pointer to a pointer to a char
c) k is a pointer to a char pointer
d) k is a pointer to a pointer to a char



10. What will be the output of the program.
char *p = 0;
char *t = NULL;

a) Yes
b) No



- Related Topics