# Palindrome in C without Using String Functions: A Comprehensive Guide

## Introduction

In this blog post, we’ll explore the concept of palindromes and delve into the details of writing a C program to check whether a given string is a palindrome. The unique aspect of this program is that it won’t use standard string functions like strlen() or array indexing to reverse the string. We’ll discuss the definition of palindromes, provide a step-by-step explanation of the algorithm, present complete C code without using string functions, and include examples with outputs.

## Understanding Palindromes

A palindrome is a sequence of characters that reads the same forward as backward. This property holds true for words, phrases, numbers, and other sequences of characters. Examples of palindromic words include “radar,” “level,” and “civic.” Similarly, palindromic phrases and numbers exhibit symmetry when read in reverse.

## Algorithm for Palindrome Checking without String Functions

The algorithm for checking whether a given string is a palindrome without using string functions involves iterating through the string from both ends and comparing characters. Here’s a step-by-step breakdown of the algorithm:

1. Input: Receive the string to be checked for palindromicity.

2. Initialization: Set two pointers, one at the beginning and one at the end of the string.

3. Comparison: Compare the characters at the pointers. If they are equal, move the pointers towards each other. If they are not equal, the input is not a palindrome.

4. Repeat: Repeat the comparison and pointer movement until the pointers meet in the middle.

5. Palindrome Check: If the pointers meet, the input is a palindrome; otherwise, it is not.

## Palindrome Program in C without String Functions

Now, let’s implement the palindrome-checking algorithm in a C program without using standard string functions.

#include <stdio.h>

int isPalindrome(char str[]) {
int start = 0;
int end = 0;

// Move 'end' to the last character of the string
while (str[end] != '\0') {
end++;
}
end--;

// Check for palindrome
while (start < end) {
if (str[start] != str[end]) {
return 0; // Not a palindrome
}
start++;
end--;
}

return 1; // Palindrome
}

int main() {
char inputString[100];

printf("Enter a string: ");
scanf("%s", inputString);

if (isPalindrome(inputString)) {
printf("%s is a palindrome.\n", inputString);
} else {
printf("%s is not a palindrome.\n", inputString);
}

return 0;
}