IP-05.c (1201B)
1 /* 2 * Author : Amit Dutta <amitdutta4255@gmail.com> 3 * Date : 03 Jan 2026 4 * Repo : https://github.com/notamitgamer/bsc 5 * License : MIT License (See the LICENSE file for details) 6 */ 7 8 /* Write a function to check whether a given string is a palindrome. Use this function to 9 determine whether an entered string is Palindrome. */ 10 11 #include <stdio.h> 12 #include <string.h> 13 14 int isPalindrome(char[]); 15 16 int main() 17 { 18 char input[100]; 19 int len; 20 21 printf("Enter the string (Max: 100 Character): "); 22 fgets(input, sizeof(input), stdin); 23 len = strlen(input); 24 25 if (len > 0 && input[len - 1] == '\n') 26 { 27 input[len - 1] = '\0'; 28 } 29 30 if (isPalindrome(input)) 31 { 32 printf("\nInput string \"%s\" is Palindrome.", input); 33 } 34 else 35 { 36 printf("\nInput string \"%s\" is not Palindrome", input); 37 } 38 39 return 0; 40 } 41 42 int isPalindrome(char str[]) 43 { 44 char *start = str; 45 char *end; 46 int len = strlen(str); 47 48 if (len == 0) 49 { 50 return 1; 51 } 52 53 end = str + (len - 1); 54 55 while (start < end) 56 { 57 if (*start != *end) 58 { 59 return 0; 60 } 61 start++; 62 end--; 63 } 64 65 return 1; 66 }