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

int i=~0; uint j=(uint)i; j++; printf(“%d”,j);

1 Answers  


which of the function operator cannot be over loaded a) <= b)?: c)== d)*

10 Answers   Cisco, CTS, Google, HCL, HP,


FILE PROGRAMMING

0 Answers   Wipro,


1,4,8,13,21,30,36,45,54,63,73,?,?.

10 Answers   Franklin Templeton, AMB,


difference between memcpy and strcpy

1 Answers  






wht is the difference between KPO and BPO ?

2 Answers   Accenture, BPO, HCL, Infosys, HCK,


21. #define square(x) x*x main() { int i; i = 64/square(4); printf("%d",i); }

3 Answers  


What are volatile variables?

1 Answers   Mind Tree,


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

2 Answers  


program to find a smallest number in an array

15 Answers   Microsoft, Sony,


Go through the following code sinippet char a[20]; a="Hello Orcale Test"; will this compile?

4 Answers   Oracle,


Define function ?Explain about arguments?

2 Answers   Geometric Software,






Categories