This is a simple C++ program that accepts string from user and check it whether it is a palindrome or not. Below is the source code of the program :
For any query, post it as a comment below.
// Program to check whether the string is palindrome or not. #includeSource: www.LearnCandCpp.com#include #include void main() { char str[20]; int i, j; cout << "\n\t"; cout << "\n\tEnter the string "; cin >> str; // To read the string char flag = 'y'; cout << "\n\tThe entered string is "; for (i = 0; str[i] != '\0'; i++) cout << str[i]; for (j = 0, i -= 1; i>j; j++, i--) { if (str[i] != str[j]) // Checking for palindrome { flag = 'n'; break; } } if (flag == 'n') cout << " is not palindrome "; else cout << " is a palindrome"; getch(); }
For any query, post it as a comment below.
1 comment:
Below is the source code of the program :
dissertation-topics-examples.info
Post a Comment