Select chapter



functions (3.papers)
loops (1.papers)
arrays (2.papers)
structures (3.papers)
unions (1.papers)
pointers (7.papers)
null pointers (1.papers)
strings (2.papers)
misc c concepts (1.papers)
Data structures (5.papers)
linked lists (3.papers)
trees (1.papers)
basics (5.papers)
Hide

Sponsored Links


  

c pointers interview questions and answers

1
Initializing a pointer with out malloc:

what is the problem with below program?

main( )
{
int *p;
*p = 30 ;
printf ( "\n%d", *p ) ;
}
  1. No error, it prints 35.
  2. instead of *p=30; we have to do p=30.
  3. this will give compile time error, because with out mallocing pointer p, we are trying to assign value to pointer, which is wrong.
  4. this may crash at run time, because with out mallocing pointer p, we are trying to assign value to pointer, which is wrong.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
3
arrays and pointers in c:

int arr[5] = {10,20,30,40,50};    
int *p = arr;

Which of below options are correct ?
  1. (p+3) is same as *(p+3)
  2. *(p+3) is same as p[3]
  3. (p+3) is same as p[3]
  4. *(p+3) is same as &p[3]
Show Answer
Share Facebook gmail Twitter
4
Which of the below pointer declarations are same?

i. char const *p;
ii. const char *p
iii. char * const p
  1. all declarations are different.
  2. i & ii are same
  3. i & iii are same
  4. all three are same.
Show Answer
Share Facebook gmail Twitter
5
what is i in below declaration?

const int * i;
  1. i is a pointer to an integer constant.
  2. i is a constant pointer to a constant integer.
  3. invalid declaration, compile time error.
  4. i is a constant pointer to an integer.
Show Answer
Share Facebook gmail Twitter
Read more papers :