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

what is the self-referential structure?

1 Answers  


12345 1234 123 12 1

2 Answers  


code for concatination of 2 strings with out using library functions?

3 Answers  


can we declare a variable in different scopes with different data types? answer in detail

3 Answers   TCS,


where can function pointers be used?

2 Answers  






what are bitwise shift operators?

4 Answers  


in a town the percentage of men is 52 the percentage of total literacy is 48 if total percentage of literate men is 35 of the total population write a program to find the total no of the literate men and women if the population of the town is 80000

2 Answers  


void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply

0 Answers  


write a program to find out prime number using sieve case?

0 Answers   HCL,


Find Error if any in below code, Justify ur answer: struct xx { int a; struct yy { char c; struct xx* p; } struct yy* q; }

3 Answers   NDS,


write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays

0 Answers   IBM,


what are bit fields? What is the use of bit fields in a structure declaration?

0 Answers  






Categories