Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://www.facebook.com/AminproPastebin
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- #include<ctype.h>
- int palin(char str[], int offset){
- int ok = 1;
- int length = strlen(str);
- int i;
- for(i=0;i<length;i++){
- str[i]=toupper(str[i]);
- }
- if(length/2 > 0)
- ok = (str[0] == str[length - 1 - offset])?
- palin(++str, ++offset):0;
- return ok;
- }
- int main(){
- while(1){
- int i = 0;
- int ok = 0;
- char str[20];
- char ori[20];
- printf("Enter a word: ");
- scanf("%s", str);
- strcpy(ori, str);
- ok = palin(str, 0);
- switch(ok){
- case 0:
- printf("%s is not a palindrome.", ori);
- break;
- case 1:
- printf("%s is a palindrome.", ori);
- break;
- }
- printf("\n\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement