📝⚡Beginner
Check if String is Palindrome
Check palindrome string
A palindrome string reads the same forwards and backwards (e.g., "radar", "level").
Program Code
string_palindrome.c
C
1#include <stdio.h>2#include <string.h>3#include <stdbool.h>45bool isPalindrome(char str[]) {6 int left = 0;7 int right = strlen(str) - 1;8 9 while (left < right) {10 if (str[left] != str[right]) {11 return false;12 }13 left++;14 right--;15 }16 return true;17}1819int main() {20 char str[100];21 22 printf("Enter a string: ");23 scanf("%99s", str);24 25 if (isPalindrome(str)) {26 printf("\"%s\" is a Palindrome\n", str);27 } else {28 printf("\"%s\" is Not a Palindrome\n", str);29 }30 31 return 0;32}Output
Enter a string: radar
"radar" is a Palindrome
Related Examples
Want to Learn More?
Explore our comprehensive tutorials for in-depth explanations of C programming concepts.
Browse Tutorials