Sail E0 Webinar
Question

What will be output if you compile following c code ?


void main()
{
char *ptr="Placementadda";
printf("%d",-3[ptr]);
}


Options:
A .  -300
B .  -103
C .  Compile Error
D .  Garbage Value
Answer: Option B


-3[ptr]



= -*(3+ptr)



= -*(ptr+3)



= -ptr[3]


= -103  //ASCII value of character ‘e’ is 103



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers