C Program to Check if a Given String is Palindrome or Not

C Program to Check if a Given String is Palindrome or Not - Hi coders. Today, we will explore how to create a C program to check if a given string is palindrome or not. However, don't hesitate to ask any questions through the comment section below. So, let's see how the code works. Enjoy!

Test Case

Test #1
Input String : abcba
abcba is a Palindrome.

Test #2
Input String : abcde
abcba is not a Palindrome.

Source Code

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
// visit us

int main() {
    char string[50];
    bool palindrome = true;
    printf("Input String : ");
    scanf("%s", &string);
    for(int i = 0; i < strlen(string); i++){
        string[i] = tolower(string[i]);
    for(int i = 0; i < strlen(string)/2; i++){
        if(string[i] != string[strlen(string)-i-1]){
            palindrome = false;
        printf("%s is a Palindrome.", string);
        printf("%s is not a Palindrome.", string);
    return 0;

Now that you've seen how the code works, I hope this tutorial has provided a clear understanding about this topic by using C. With this knowledge, you can explore more programming concepts and create other fascinating programs. Happy coding and keep on learning on your programming journey!

Feel free to share this knowledge with others. See you in the next post!

Related Posts
Fandi Presly Simamora
Lecturer, code lover, technology enthusiast, enjoys sharing various things through writing, and of course, just a regular human being. Hello world :)

Related Posts

Post a Comment