Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main(){
- char str[1005];
- printf("Enter any string: ");
- scanf("%s",str);
- int len = 0;
- while (str[len]!='\0') ++len;
- int left = 0, right = len - 1;
- bool isPalindrome = true;
- while (left<right){
- if (str[left]!=str[right]){
- isPalindrome = false;
- break;
- }
- ++left;
- --right;
- }
- if (isPalindrome) printf("String is Palindrome.\n");
- else printf("String is not Palindrome.\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment