Write a C program to check if a string is palindrome or not, without using any inbuilt function?




#include<stdio.h>
#include<conio.h>
int length(char b[]);
void main()
{
    int i, n, len;
    char a[10];
    printf("Enter string: ");
    gets(a);
    len = length(a);
    for(i=0; i<=len; i++)
    {
        if(a[i]==a[len-1])
            printf("%s is a palindrome.",a);
        else
            printf("%s is a not palindrome.",a);
            break;
    }
    getch();
}
int length(char b[])
{
    int i, j=1;
    for(i=1; b[i]!=0; i++)
    {
        j++;
    }
    return(j);
}

Output 1:

Output 2:

 

Comments

Popular posts from this blog

Larch Soft Pvt. Ltd. - Best Website & Hosting Provider