pc-ip-05.c (1052B)
1 /* 2 * Author : Amit Dutta <amitdutta4255@gmail.com> 3 * Date : 05 Jan 2026 4 * Repo : https://github.com/notamitgamer/bsc 5 * License : MIT License (See the LICENSE file for details) 6 */ 7 8 /* 9 * Question 5: 10 * Write a function to check whether a given string is a palindrome. Use this function to determine whether an entered string is Palindrome. 11 */ 12 13 #include <stdio.h> 14 15 int isPalindrome(char[]); 16 17 int main() 18 { 19 char str[51]; 20 printf("Please enter the string (Max: 50 character): "); 21 gets(str); 22 if (isPalindrome(str)) 23 { 24 printf("\nInput string is a palindrome string."); 25 } 26 else 27 { 28 printf("\ninput string is not a palindrome string."); 29 } 30 return 0; 31 } 32 33 int isPalindrome(char str[]) 34 { 35 int low = 0; 36 int high = 0; 37 while (str[high] != '\0') 38 { 39 high++; 40 } 41 high--; 42 if (low == high) 43 { 44 return 1; 45 } 46 while (low < high) 47 { 48 if (str[low] != str[high]) 49 { 50 return 0; 51 } 52 low++; 53 high--; 54 } 55 return 1; 56 }