AIM: Write A Program That Checks Whether The Entered String Is A
AIM: Write A Program That Checks Whether The Entered String Is A
H – 49
THEORY:
Logic –
1st we take a string as input and store in the array str[].
Then we ask to user to enter the string.
Then using for loop, we compare elements of array str[]in
reverse patter.
Syntax - for(i = 0; i<len; i++)
{
if(str[i] != str[len - i -1])
{
flag = 0;
break;
}
}
In this code we use break statement to break the chain of code.
If all the elements are same in reverse pattern also then we
print “Entered string is a palindrome.”; otherwise we print
“Entered string is not a palindrome.”, by using if - else
statement.
CONCLUSION:
• A palindrome is a word, number, phrase, or other
sequence of characters which reads the same backward
as forward, such as madam or racecar. There are also
numeric palindromes, including date/time stamps using
short digits 11/11/11 11:11 and long
digits 02/02/2020. Sentence-length palindromes ignore
capitalization, punctuation, and word boundaries.