Posts

Showing posts with the label C Aptitude Questions and Answers(Part-1)

C Aptitude Questions and Answers(Part-1)

Image
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". 2.    main() {             char s[ ]="man";             int i;             for(i=0;s[ i ];i++)             printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); } Answer:                     ...