Multiple choice technology programming languages

Code: char* myFunc (char *ptr) { ptr += 3; return (ptr); } int main() { char *x, *y; x = "HELLO"; y = myFunc (x); printf ("y = %s \n", y); return 0; } What will print when the sample code above is executed?

  1. y = LLO

  2. y = LO

  3. y = ELLO

  4. y = HELLO

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

The function increments the pointer by 3 characters. 'HELLO' + 3 points to 'LO' (the 4th character, index 3). Pointer arithmetic moves forward by 3 positions, so ptr goes from 'H' to 'L'. printf then prints 'LO'. Option B is correct. Options A ('LLO') would be +2, C ('ELLO') would be +1, D would be no pointer change.