-->

Program to know a string is Palindrome or not

in turboc++
------------------------------------------------------------------------------------------------------
//program to know a string is Palindrome or not
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char string[100],string1[100];
    printf("enter string\n");
    gets(string);//accepts string
    strcpy(string1,string);//copies string to another
    strrev(string);//reverses the string
    if((strcmp(string,string1)==0))//compares the strings are same or not
    {
        printf("it is palindrome");

    }
    else
    {
        printf("it is not palidrome");
    }

     getch();
    return 0;
}
--------------------------------------------------------------------------------------------------
in codeblocks:
--------------------------------------------------------------------------------------------------
//program to know a string is Palindrome or not
#include <stdio.h>
#include<string.h>
int main()
{
    char string[100],string1[100];
    printf("enter string\n");
    gets(string);//accepts string
    strcpy(string1,string);//copies string to another
    strrev(string);//reverses the string
    if((strcmp(string,string1)==0))//compares the strings are same or not
    {
        printf("it is palindrome");

    }
    else
    {
        printf("it is not palidrome");
    }


    return 0;
}

No comments:

Post a Comment