Is there any way to fix this bug? I would like to print the string array but if some of the element is not a or c, it has to change the letter to X. why it doesn't print?
You used the logical-or operator instead of the logical-and operator. It can't be both a and c at the same time, so one of the conditions always fails.