GeekInterview.com
Series: Subject: Topic:
Question: 289 of 827

Write a C program to check given string is palindrome or not using pointers?

Asked by: Interview Candidate | Asked on: Aug 17th, 2007
Showing Answers 1 - 2 of 2 Answers
baseersd

Answered On : Jan 7th, 2008

View all answers by baseersd

#include<stdio.h>int Ispalindrome(char* str){     int i,len;    len = strlen(str);    for(i = 0; i < len / 2; i++)    {          if( *(str +i ) != *(str + len - i - 1) )                   return 0;        }    return 1;}int main(){    char string[20]="";    printf("Enter the string ::");    gets(string);    if( Ispalindrome(string))        printf("n%s is a palindromen",string);    else        printf("n%s is not a palindromen",string); system("pause");    }

  
Login to rate this answer.
aks3937

Answered On : Aug 24th, 2009

View all answers by aks3937

#include<stdio.h>#include<conio.h>void main(){int i,flag=0,k,l,m,n;char str[100];clrscr();printf("enter the string n");scanf("%s",str);l=strlen(str);printf("%d",l);l=l-1;i=0;while(strcmp(str[i],str[l])==0){if(i+1==l){printf("its a palindromen");flag=1;break;}i++;l--;if(i==l&&(strcmp(str[i],str[l])==0)){printf("its a palindromen");flag=1;break;}}if(flag==0)printf("its not a palindromen");getch();}

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.