Pointers Questions and Answers

Practice Mode
Showing 10 of 217 questions
Q171
Which of the following statement is true ?
  • A The address of operator & requires 1value as its operand where as indirection operator (*) returns an 1value.
  • B the address of operator (&) returns operator (*) returns an 1value
  • C Both address of operator *(&) teturns an 1value where as indirection operator (*) requires an 1value
  • D Both address of operator (&) and indirection operator (*) requires an 1value.
Answer: Option D
Q172
Find the output. void main () { int *p; const int i=10; p=&i; printf "%d %d", *p, ++*p); }
  • A 10 11
  • B 11 11
  • C Can not modify a constant object
  • D None of these
Answer: Option B
Q173
Find the output void main ( ) int *p; float a[5]; for (p=a; p<&a [5]; p++) { *p=p-a; printf("%d", *p); } }
  • A 01234
  • B 0123456789
  • C 12345
  • D Error: Integer pointer can't be assigned to float array.
Answer: Option B
Q174
Find the output void main ( ) { char *p="abc123", *q="abc"; while *p++=*q++) printf("%c%c", *p,*q); }
  • A aabbcc
  • B bbcc112233
  • C bbcc1
  • D aabbcc123
Answer: Option C
Q175
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"; }
  • A Null pointer assignment
  • B Error: return "MAGIC" has to be written return ("MAGIC")
  • C Error:ptr=sp( ), can't modify const object
  • D Error:return may return a char butnot a string
Answer: Option C
Q176
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); }
  • A 1 1
  • B 1 2
  • C 2 2
  • D None of these
Answer: Option A
Q177
Find the output void main ( ) { int *p [ ] = {1, 45, 78, 100}; printf("%d", sizeof (p) / sizeof (int*)); }
  • A 1
  • B 4
  • C 2
  • D Compilation error
Answer: Option B
Q178
Find the output void main ( ) { char *p="Tuni"; reverse (p); printf("%s",p); } reverse (char *q) { char *r="Hello"; q=r; printf("&s", q); }
  • A Hello Hello
  • B Tuni
  • C Hello Tuni
  • D Invalid function cal
Answer: Option C
Q179
Find the output void main ( ) { const char *p="CIMPLE"; p++; *p='a'; printf("%s",p); }
  • A IMPLE
  • B Error:*='a', can not modify constant object
  • C Error:p can not be incremented.
  • D IMPLE and garbage
Answer: Option C
Q180
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); }
  • A 3 5
  • B 3 3
  • C 5 5
  • D Compilation error
Answer: Option C
Questions and Answers for Competitive Exams Various Entrance Test