Pointers Questions and Answers

Take Exam

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

171. Which of the following statement is true ?

  • The address of operator & requires 1value as its operand where as indirection operator (*) returns an 1value.
  • the address of operator (&) returns operator (*) returns an 1value
  • Both address of operator *(&) teturns an 1value where as indirection operator (*) requires an 1value
  • Both address of operator (&) and indirection operator (*) requires an 1value.
Show Answer Report

172. Find the output. void main () { int *p; const int i=10; p=&i; printf "%d %d", *p, ++*p); }

  • 10 11
  • 11 11
  • Can not modify a constant object
  • None of these
Show Answer Report

173. Find the output void main ( ) int *p; float a[5]; for (p=a; p<&a [5]; p++) { *p=p-a; printf("%d", *p); } }

  • 01234
  • 0123456789
  • 12345
  • Error: Integer pointer can't be assigned to float array.
Show Answer Report

174. Find the output void main ( ) { char *p="abc123", *q="abc"; while *p++=*q++) printf("%c%c", *p,*q); }

  • aabbcc
  • bbcc112233
  • bbcc1
  • aabbcc123
Show Answer Report

175. Find the output #include "stdio.h" void main ( ) char *const fp); char *const ptr; ptr=fp( ); printf ("\n %s", ptr); } char *const fp( ) { return "MAGIC"; }

  • Null pointer assignment
  • Error: return "MAGIC" has to be written return ("MAGIC")
  • Error:ptr=sp( ), can't modify const object
  • Error:return may return a char butnot a string
Show Answer Report

176. Find the output int a[ ] = {1, 2, 3, 4, 5}: void main ( ) { int *p, *q, i; p=a; q=a+2; i=*p++; printf("%d %d", i, q-p); }

  • 1 1
  • 1 2
  • 2 2
  • None of these
Show Answer Report

177. Find the output void main ( ) { int *p [ ] = {1, 45, 78, 100}; printf("%d", sizeof (p) / sizeof (int*)); }

  • 1
  • 4
  • 2
  • Compilation error
Show Answer Report

178. Find the output void main ( ) { char *p="Tuni"; reverse (p); printf("%s",p); } reverse (char *q) { char *r="Hello"; q=r; printf("&s", q); }

  • Hello Hello
  • Tuni
  • Hello Tuni
  • Invalid function cal
Show Answer Report

179. Find the output void main ( ) { const char *p="CIMPLE"; p++; *p='a'; printf("%s",p); }

  • IMPLE
  • Error:*='a', can not modify constant object
  • Error:p can not be incremented.
  • IMPLE and garbage
Show Answer Report

180. Find the output void fun (int *a,int *b) { int *t; t=a, a=b, b=a; printf("%d %d", 8a, *b); } void main ( ) { int a=3; void fun ( ); int b=5; fun (&a, &b); }

  • 3 5
  • 3 3
  • 5 5
  • Compilation error
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test