helsinki2103

hehe

Jan 31st, 2021 (edited)
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main(){
  4.     char str[1005];
  5.     printf("Enter any string: ");
  6.     scanf("%s",str);
  7.     int len = 0;
  8.     while (str[len]!='\0') ++len;
  9.     int left = 0, right = len - 1;
  10.     bool isPalindrome = true;
  11.     while (left<right){
  12.         if (str[left]!=str[right]){
  13.             isPalindrome = false;
  14.             break;
  15.         }
  16.         ++left;
  17.         --right;
  18.     }
  19.     if (isPalindrome) printf("String is Palindrome.\n");
  20.     else printf("String is not Palindrome.\n");
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment