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 c program to read a positive number and display it in words.? ex: 123=one two three help me....

2 Answers  


how to compare two strings without using strcmp() function??

1 Answers  


What is dangling pointer in c?

0 Answers  


What is the use of pointers in C?

0 Answers   Impetus, Motorola, Tavant Technologies, Virtusa,


What is sizeof c?

0 Answers  






How are pointers declared in c?

0 Answers  


What are extern variables in c?

0 Answers  


How would you write qsort?

1 Answers  


In which header file is the null macro defined?

0 Answers  


What is the right way to use errno?

0 Answers  


How to run c Program without using IDE of c. means if program made in notepad.then how to compile by command prompt.

1 Answers   HP, TCS,


What is register variable in c language?

0 Answers  


Categories