🎴 Flashcard Mode
Java and C Programming Quiz
Card1 / 7
Mastered0
Review0
QuestionClick to flip
char* riteshFunc (char *ptr) { ptr += 3; return (ptr); } int main() { char *x, *y; x = "HELLO"; y = riteshFunc(x); printf ("y = %s \n", y); return 0; } What will print when the sample code above is executed?
AnswerClick to flip back
A
LO
💡 Explanation:
Pointer arithmetic moves the pointer 3 characters forward from H-E-L-L-O, so it points to L-L-O. The printf outputs from that position, printing LO. Options A, B, and C are incorrect pointer offsets.