Showing posts with label c-aptitude. Show all posts
Showing posts with label c-aptitude. Show all posts

Monday, May 9, 2011

C - Aptitude Questions 51-150


51) main( )
{ void *vp; char ch = ‘g’, *cp = “goofy”; int j = 20; vp = &ch; printf(“%c”, *(char *)vp); vp = &j; printf(“%d”,*(int *)vp); vp = cp; printf(“%s”,(char *)vp + 3);
}
Answer:
g20fy
Explanation:

Sunday, May 8, 2011

C - Aptitude Questions 1-46

Predict the output or error(s) for the following:
1. void main()
{ int const * p=5; printf("%d",++(*p));
}
Answer:
Compiler error: Cannot modify a constant value. Explanation: p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".