Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- void isPalindrome(char str[])
- {
- int i, length;
- int flag = 0;
- length = strlen(str);
- if (length > 100)
- {
- cout << "String has characters exceeding the limit!";
- }
- else {
- for (i = 0; i < length; i++) {
- if (str[i] != str[length - i - 1]) {
- flag = 1;
- break;
- }
- }
- if (flag) {
- cout << "The string '" << str << "' is NOT a palindrome!" << endl;
- }
- else {
- cout << "The string '" << str << "' IS a palindrome!" << endl;
- }
- }
- }
- int main() {
- char str[100];
- cout << "Enter a string: ";
- cin >> str;
- isPalindrome(str);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement