C Program to Check if the string is palindrome or not - Source Code, Output & Execution Flow

C Program to Check if the string is palindrome or not

This tutorial explains c program to check if the string is palindrome or not with C source code, sample output, and step-by-step execution flow.

#include <stdio.h>
#include <string.h>
int main() {
    char str[] = "level";
    int i, len = strlen(str), flag = 1;
    for (i = 0; i < len / 2; i++) if (str[i] != str[len - i - 1]) flag = 0;
    if (flag) printf("Palindrome string
");
    else printf("Not a palindrome string
");
    return 0;
}
Palindrome string

In this program, the input is read first when required, the core logic is applied step by step, and the final result is displayed using printf(). Follow the execution flow beside the code to understand how each statement contributes to the output.

Sai Kishore Randhi, author
About the author

Sai Kishore Randhi

Embedded systems, VLSI, and chip design

Sai Kishore writes about embedded systems, VLSI, chip design, and the programming concepts behind modern hardware.

View LinkedIn profile ↗