Pointers Questions and Answers
Pointers questions with answers are a crucial part of C programming preparation, often included in technical interviews and MCQ-based exams. Pointers are variables that store the memory address of other variables, making them fundamental to dynamic memory management and efficient program design. These C programming MCQ questions and answers help students understand pointer arithmetic, function pointers, arrays, and memory allocation. Commonly asked in placement exams by TCS, Infosys, and Wipro, mastering pointer concepts gives you a competitive edge in coding tests and programming interviews.
Pointers
Showing 10 of
217 questions
121. main ( ) { char *a [ ] = {"jaya", "mahe", "chandra", "buchi"}; printf ("%d", sizeof (a) / sozeof (char *)); }
- 4
- bytes for char
- bytes for char*
- error
122. main ( ) { char *p = "abc"; char *q = "abc123"; while (*p++=*q++) { printf ("%c%c, *p, *q); } } What will be the output of the above ?
- aabbcc
- aabbcc123
- abcabc123
- bbcc1a2b3c
123. What is the result of the expression for the following declaration ? int A [ ] = {1, 2, 3, 4, 5 }; *A + 1 - *A +3
- 2
- -2
- 4
- none of the above
124. Which are valid ? (i)Pointers can be added; (ii)Pointers can be subtracted. (iii)Integers can be added to pointers.
- all correct
- only options (i) and (ii)
- only option (iii)
- only options (ii) and (iii)
125. x = malloc (y). Which off the following statements is correct ?
- x is the size of the memory allocated
- y Points to the memory allocated
- x points to the memory allocated
- none of the above
126. 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
- all
- options (i) and (ii)
- option (iii) is valid sometimes
- none of the above
127. int *i; float *f; char *c; Which are the valid castings ? (i) (int *) &c (ii) (float *) &c (iii) (char *) &i
- options (i), (ii) and (iii)
- only options (i) and (iii)
- only option (iii)
- only options (i) and (ii)
128. 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 address of the variable b
- 'a' 'b'
- 'a' address of the value b in "b"
- a b
129. 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?
- S.T.S.
- STS
- ST
- S.T.
130. Find the output void main() { int a[5]={2, 3, 4, 5}, *c=a; (*c) --; printf ("d", *c); }
- 4
- 1
- 2
- Pointer can't be decremented