My Subject Blog

C Program to Find String is Palindrome or not

/*
Write a program to check whether given String is Palindrome or not. 
*/

#include <stdio.h>

int main(void) 
{
    char str[100];
    int i=0,j=0;
    printf("Enter the First String : ");
    scanf("%s",str);
    for(j=0;str[j]!='\0';j++)
    {

    }
    j--;

    while(i<j)
    {
    if(str[i]!=str[j])
    {
    break;
    }
    i++;
    j--;
    }
    if(i<j)
    {
    printf(" String : %s is not palindrome",str);
    }
    else
    {
    printf(" String : %s is palindrome",str);
    }
return 0;
}

Comments

Most Visited Post

C Program to Find Largest Odd Number from Array

Followers