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

201. Find the output void main ( ) { int a=5, b=7; int *p; p=&a; p--; *p=10; printf("%d %d", a, b); }

  • 5 7
  • 5 10
  • 10 7
  • Garbage 7
Show Answer Report

202. What is major difference between malloc and calloc ?

  • Malloc initializes it memory location with garbage but calloc initializes with 0
  • Malloc memory allocation is single dimensional array equivalent and calloc memory allocation is double dimensional array equivalent
  • Malloc takes only one parameter but calloc takes two parameter
  • None of these
Show Answer Report

203. Find the output void main ( ) { char *s1="alpha", *s2="alpha"; if (!strcmp (s1, s2)) printf("%d", *s1+*s2); }

  • 97
  • 194
  • Garbage
  • Compilation eror
Show Answer Report

204. After we free an allocated memory block using free (), the pointer will become

  • Null pointer
  • Danging pointer
  • Wild pointer
  • Smart pointer
Show Answer Report

205. Consider the following declarations: int a[10]; int *p=a; Which amot the following is portable way to print value of pointer p?

  • printf ("%u\n", *p);
  • printf("%d\n", p);
  • printf("%1u",p);
  • printf("%p\n", (void*);
Show Answer Report

206. Find the output int man () { char *cp=NULL; { char  c; cp=&c; } return 0; } After the execution of above inner block

  • Pointer cp is dead
  • Pointer cp is still alive and is dangling pointer
  • Pointer cp is dead and again points to NULL
  • Pointer cp is alive and acessing it will error.
Show Answer Report

207. Modifying the object's value pointed by dangling pointer can cause I. Change in object's value unexpectedly II. Memory corruption III. Null pointer assinment IV. Error: Constant object can't modidy

  • Only (i) is true
  • Only (iii) is true
  • Both (i) and (ii) is true
  • Both (ii) and (iv) is true.
Show Answer Report

208. Find the output void main ( ) { int *p, *q; p=(float *) 2000; q=(char *) 3000; printf("%d", q-p); }

  • 500
  • 1000
  • 2000
  • Compilation Error
Show Answer Report

209. Find the output void main () { int *p = (int *)50; int *q; q=p+5; printf("%c", (q-p) + 62); }

  • graphic char
  • char A
  • Char C
  • Err: illegal pointer airthametic
Show Answer Report

210. What is true about the following statement typedef int (*mass) (char*, char*); mass m1, m2;

  • m1 and m2 are pointers to function that accept two char pointers and returns an int
  • m1 and m2 are not defined
  • mass is a function returning int whih points to two char
  • Declaration error
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test