write a function to find whether a string is palindrome or
not and how many palindrome this string contain?




Answers were Sorted based on User's Feedback



write a function to find whether a string is palindrome or not and how many palindrome this string..

Answer / nm

bool palindrome(char *str){
char *ptr1 = str;
char *ptr2 = str + strlen(str) - 1;

while(ptr1 < ptr2){
if(*ptr1 != *ptr2)
return false;
ptr1++;
ptr2--;
}

return true;

}

Is This Answer Correct ?    30 Yes 29 No

write a function to find whether a string is palindrome or not and how many palindrome this string..

Answer / nadeem

bool palindrome(char *str){
char *ptr1 = str;
char *ptr2 = str + strlen(str) - 1;

while(ptr1 < ptr2){
if(*ptr1++!= *ptr2--)
return false;// not palindrome

}

return true;//palindrome


}

Is This Answer Correct ?    3 Yes 6 No

Post New Answer




More C Interview Questions

Write a pro-gramme to determine whether the number is even or odd?

1 Answers  


what is real time system?what is the differance between hard and soft real time systems

2 Answers  


What is the Difference between Class and Struct?

10 Answers   Motorola,


int j =15,i; for (i=1; 1<5; ++i) {printf ("%d%d ",j,i); j = j-3; }

2 Answers  


2.main { int x,j,k; j=k=6;x=2; x=j*k; printf("%d", x);

8 Answers   HCL, Tech Mahindra,






what is a function method?give example?

0 Answers  


How can I increase the allowable number of simultaneously open files?

1 Answers   ABC,


what is the output of printf("%d",(scanf("%d",10));

10 Answers  


how to find the kth smallest element in the given list of array elemnts.

8 Answers   Silicon,


What is the difference between File pointer and Internal Charecter Pointer?

2 Answers   TATA,


What is the output of the below program and how it is? void main() { static int var=5; printf("%d",var--); if(var) main(); }

7 Answers   TCS, Tech Mahindra, MindFire,


Meaning of () in c

1 Answers  






Categories