Sunday, 22 October 2017

Checking Palindrome using Command Prompt

#include<stdio.h>
int main(int argc, char * argv[])
{
    int i,j,l,flag=1,k=0;
    char a[50];
    //printf("Enter a string: ");
    if(argc==1)
        exit(1);
    for(i=1;i<argc;i++)
    {
        for(j=0;argv[i][j];j++)
        {
            a[k]=argv[i][j];
            k++;
        }
    }
    i=0;
    j=0;
    for(l=0;a[l]!='\0';l++);
    j=l-1;
    for(i=0;i<=l/2;i++)
    {
        if(a[i]!=a[j])
            flag=0;
        j--;
    }
    if(flag==1)
        printf("Palindrome");
    else
        printf("Not Paliindrome");

    return 0;



}

No comments:

Post a Comment

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...