Multiple choice

What will be the output of the following function?

include <stdio.h>

void main() { char str[10] = “Angel”; str[6] ='d'; printf(“%s”,str); }

  1. Angel d

  2. d

  3. Angel

  4. Error

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

The string 'Angel' is stored with a null terminator at index 5. Modifying the character at index 6 does not affect the null terminator at index 5, so printf stops at the end of 'Angel'.