Palindrome Test Cases Passed But Why? 5 or '5'

When i was using a character array and takin input from cin directly without loop the i was only able to pass 2 test cases.

but as I replaced that with int array and used loop to take input,all test cases were passed.

why this happened??? as it should not matter if it is 5 or ‘5’

hello @Khushwant
input is not given in single line ie all n values are in n different lines , so u cannot read all charaters without using loop. thats why u were facing issue when u r trying without loop

1 Like

to read more than 1 input we need loop right?

Sir but in case of char array we can read input from a single cin instead of using a loop

yeah we can but only when they are given in a single row right?
in our case input is given in different lines .

Sir but finally they have to be stored in an array and we have to check whether that array is palindrome or not

Sir I understood what my mistake was…if I used a char array and gave input like in question it will always return true because now instead of whole array ,each individual chracter will be checked if palindrome and as every character is a palindrome it will always return true

Sir let me know if it is correct

Thanks a lot for your help Sir

yeah in ur current code , u are only checking the very first character .
and a character is always a palindrome thats why it is alwsys returning true