Write a MATLAB program for check given string is palindrome or not


Code:

clear
clc
%2. Input a string.
string = input('What is your string: ', 's');
%3. Check if the string is a palindrome or not.
if string == fliplr(string);
disp (['The string, ' string ', is a palindrome.']);
else
disp (['The string, ' string ', is not a palindrome.']);
end

 

Output:






No comments

Powered by Blogger.