AedenCak3

C program to check if an input string is a palindrome

Dec 9th, 2021 (edited)
816
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include<stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7.    char str[100];
  8.    int i, size, counter=0;
  9.  
  10.    printf("Enter a string:");
  11.    gets(str);
  12.  
  13.    size=strlen(str);
  14.    for(i=0;i<size;i++){
  15.     if (str[i]!=str[size-i-1]){
  16.         counter=1;
  17.         break;
  18.     }
  19.    }
  20.    if(counter==0)
  21.    {
  22.        printf("Its a palindrme");
  23.    }
  24.    else{
  25.     printf("Not a palindrome");
  26.  
  27.    }
  28.  return 0;
  29. }
  30.  
  31.  
Add Comment
Please, Sign In to add comment