How can I create a function for palindrome ? Anyone can help me with.
1 view (last 30 days)
Show older comments
Abdulrehman Khan
on 28 Nov 2016
Commented: Abdulrehman Khan
on 28 Nov 2016
Write a testPalindromes() function that accepts a string then returns true if the string reads the same backwards as forwards and false otherwise. (Do NOT use loops) Thanks In Advance
1 Comment
Jan
on 28 Nov 2016
As in the other discussions about palindromes in this forum (note: searching the internet will reveal solutions already...), the handling of spaces and upper/lower-case must be defined.
Accepted Answer
KSSV
on 28 Nov 2016
str = 'civic' ;
% str = 'cool' ;
if strcmpi(str,fliplr(str))
fprintf('yes %s is a palindrome \n',str)
else
fprintf('no %s is not a palindrome \n',str)
end
3 Comments
KSSV
on 28 Nov 2016
@Jan Simon, mostly I don't answer HW questions. I found this to be simple, I don't think this to be a HW problem.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!