0% found this document useful (0 votes)
21 views2 pages

AIM: Write A Program That Checks Whether The Entered String Is A

The document discusses a program that checks if a string is a palindrome without using string header files. It takes input from the user, stores it in an array, then uses a for loop to compare the first and last elements, then second and second last, and so on to see if they are equal in reverse. If all matches it prints palindrome, otherwise not palindrome.

Uploaded by

John Wick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

AIM: Write A Program That Checks Whether The Entered String Is A

The document discusses a program that checks if a string is a palindrome without using string header files. It takes input from the user, stores it in an array, then uses a for loop to compare the first and last elements, then second and second last, and so on to see if they are equal in reverse. If all matches it prints palindrome, otherwise not palindrome.

Uploaded by

John Wick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Vansh Rohra

H – 49

AIM: Write a program that checks whether the entered string is a


palindrome or not, without using string header file.

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.

You might also like