Multiple choice general knowledge

What will be the output for... main() { char p1=“name”; char *p2; p2=(char)malloc(20); memset (p2, 0, 20); while(*p2++ = *p1++); printf(“%sn”,p2); }

  1. p1

  2. p2

  3. empty string

  4. name

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The while loop copies 'name' to p2 but both p1 and p2 are incremented after each assignment. When the loop exits, p2 points to the null terminator, so printf(%s, p2) prints an empty string. The key is understanding post-increment behavior.