© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

C and C++ Interview Questions

6.   How are pointer variables initialized?

Ans:
Pointer variable are initialized by one of the following two ways
- Static memory allocation
- Dynamic memory allocation
Pointer variable are initialized by one of the following two ways
- Static memory allocation
- Dynamic memory allocation

Ex - 1:  What is the output?
main()
{         
char *p = “ayqm”;
printf(“%c”,++*(p++));
}

Ans:
b

Ex - 2 what is the output?:

main()
{
char *p = “ayqm”;
char c;
c = ++*p++;
printf(“%c”,c);
}

Ans:
b

Explanation:

There is no difference between the expression ++*(p++) and ++*p++. Parenthesis just works as a visual clue for the reader to see which expression is first evaluated.


SLogix Student Projects
bottom