Pointers Questions and Answers

Practice Mode
Showing 10 of 217 questions
Q121
main ( ) { char *a [ ]  = {"jaya", "mahe", "chandra", "buchi"}; printf ("%d", sizeof (a) / sozeof (char *)); }
  • A 4
  • B bytes for char
  • C bytes for char*
  • D error
Answer: Option A
Q122
main ( ) { char *p = "abc"; char *q = "abc123"; while (*p++=*q++) { printf ("%c%c, *p, *q); } } What will be the output of the above ?
  • A aabbcc
  • B aabbcc123
  • C abcabc123
  • D bbcc1a2b3c
Answer: Option D
Q123
What is the result of the expression for the following declaration ? int A [ ] = {1, 2, 3, 4, 5 }; *A + 1 - *A +3
  • A 2
  • B -2
  • C 4
  • D none of the above
Answer: Option C
Q124
Which are valid ? (i)Pointers can be added; (ii)Pointers can be subtracted. (iii)Integers can be added to pointers.
  • A all correct
  • B only options (i) and (ii)
  • C only option (iii)
  • D only options (ii) and (iii)
Answer: Option C
Q125
x = malloc (y). Which off the following statements is correct ?
  • A x is the size of the memory allocated
  • B y Points to the memory allocated
  • C x points to the memory allocated
  • D none of the above
Answer: Option C
Q126
p and q are pointers to the same type of data items. Which of these are valid ? (i) *(p+q) (ii) *(P-q) (iii) *p-*q
  • A all
  • B options (i) and (ii)
  • C option (iii) is valid sometimes
  • D none of the above
Answer: Option C
Q127
int *i; float *f; char *c; Which are the valid castings ? (i) (int *) &c (ii) (float *) &c (iii) (char *) &i                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  • A options (i), (ii) and (iii)
  • B only options (i) and (iii)
  • C only option (iii)
  • D only options (i) and (ii)
Answer: Option A
Q128
int a = 'a', d = 'd'; char *b = "b", **c = "cr"; main ( ) { mixup (a, b, &c); } mixup (int p1, char *p2, chr **p3) { int *temp; ... } What is the value of a and b in mixup at the beginning ?
  • A a address of the variable b
  • B 'a' 'b'
  • C 'a' address of the value b in "b"
  • D a b
Answer: Option C
Q129
main ( ) { char s [ ] = "S.T.S.", *A; print (s); { print (char *p) { while (*p ! = '\0') { if (*p ! = '' . ') printf ("%c", *p); p++; } } What is the output?
  • A S.T.S.
  • B STS
  • C ST
  • D S.T.
Answer: Option B
Q130
Find the output void main() { int a[5]={2, 3, 4, 5}, *c=a; (*c) --; printf ("d", *c); }
  • A 4
  • B 1
  • C 2
  • D Pointer can't be decremented
Answer: Option B
Questions and Answers for Competitive Exams Various Entrance Test