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



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

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

HOW TO SWAP TWO NOS IN ONE STEP?

16 Answers   Satyam,


What is the Lvalue and Rvalue?

2 Answers  


Write a program in C to reverse a number by recursive function?

1 Answers  


how many argument we can pas in in a function

25 Answers   CTS,


what is self refrential structure

3 Answers   HCL,






what is the purpose of the following code, and is there any problem with the code? void fn(long* p1, long* p2) { register int x = *p1; register int y = *p2; x ^= y; y ^= x; x ^= y; *p1 = x; *p2 = y; }

1 Answers   Google,


find out largest elemant of diagonalmatrix

0 Answers  


I need to take a sentence from input and sort the words alphabetically using the C programming language. Note: This is C not C++. qsort and strtok not allowed

4 Answers   Aspire,


Is the following code legal? struct a { int x; struct a b; }

4 Answers  


Program to trim a given character from a string.

5 Answers   NetApp,


write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]

7 Answers  


how many keywords do C compile?

7 Answers   Microsoft, Practical Viva Questions,






Categories