Pointers Questions and Answers

Practice Mode
Showing 10 of 217 questions
Q201
Find the output void main ( ) { int a=5, b=7; int *p; p=&a; p--; *p=10; printf("%d %d", a, b); }
  • A 5 7
  • B 5 10
  • C 10 7
  • D Garbage 7
Answer: Option B
Q202
What is major difference between malloc and calloc ?
  • A Malloc initializes it memory location with garbage but calloc initializes with 0
  • B Malloc memory allocation is single dimensional array equivalent and calloc memory allocation is double dimensional array equivalent
  • C Malloc takes only one parameter but calloc takes two parameter
  • D None of these
Answer: Option B
Q203
Find the output void main ( ) { char *s1="alpha", *s2="alpha"; if (!strcmp (s1, s2)) printf("%d", *s1+*s2); }
  • A 97
  • B 194
  • C Garbage
  • D Compilation eror
Answer: Option B
Q204
After we free an allocated memory block using free (), the pointer will become
  • A Null pointer
  • B Danging pointer
  • C Wild pointer
  • D Smart pointer
Answer: Option A
Q205
Consider the following declarations: int a[10]; int *p=a; Which amot the following is portable way to print value of pointer p?
  • A printf ("%u\n", *p);
  • B printf("%d\n", p);
  • C printf("%1u",p);
  • D printf("%p\n", (void*);
Answer: Option A
Q206
Find the output int man () { char *cp=NULL; { char  c; cp=&c; } return 0; } After the execution of above inner block
  • A Pointer cp is dead
  • B Pointer cp is still alive and is dangling pointer
  • C Pointer cp is dead and again points to NULL
  • D Pointer cp is alive and acessing it will error.
Answer: Option B
Q207
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
  • A Only (i) is true
  • B Only (iii) is true
  • C Both (i) and (ii) is true
  • D Both (ii) and (iv) is true.
Answer: Option C
Q208
Find the output void main ( ) { int *p, *q; p=(float *) 2000; q=(char *) 3000; printf("%d", q-p); }
  • A 500
  • B 1000
  • C 2000
  • D Compilation Error
Answer: Option A
Q209
Find the output void main () { int *p = (int *)50; int *q; q=p+5; printf("%c", (q-p) + 62); }
  • A graphic char
  • B char A
  • C Char C
  • D Err: illegal pointer airthametic
Answer: Option C
Q210
What is true about the following statement typedef int (*mass) (char*, char*); mass m1, m2;
  • A m1 and m2 are pointers to function that accept two char pointers and returns an int
  • B m1 and m2 are not defined
  • C mass is a function returning int whih points to two char
  • D Declaration error
Answer: Option A
Questions and Answers for Competitive Exams Various Entrance Test