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 the output of following code .. main() { static int a[]={10,20,30,40,50}; int *ptr=a; static int arr[2][2]={1,2,3,4}; char str[]="ABCD * 4#"; char *s=str+2; int i,j; for(i=0;i<5,i++) printf("%d",*ptr++); for(i=0;i<2;i++) for(j=0;j<2;j++) printf("%d\n",*(*(n+i)+j)); printf("%c\n%c\n%c\n",*(str+2),*s++,*--s); }

1 Answers  


What is the difference between c and python?

0 Answers  


What is a protocol in c?

0 Answers  


What does == mean in texting?

0 Answers  


If I have a char * variable pointing to the name of a function ..

0 Answers  






What is the difference between array and pointer in c?

0 Answers  


How many levels of indirection in pointers can you have in a single declaration?

0 Answers   Agilent, ZS Associates,


Explain how can a program be made to print the line number where an error occurs?

0 Answers  


"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above

0 Answers  


What kind of sorting is this? SORT (k,n) 1.[Loop on I Index] repeat thru step2 for i=1,2,........n-1 2.[For each pass,get small value] min=i; repeat for j=i+1 to N do { if K[j]<k[min] min=j; } temp=K[i];K[i]=K[min];K[min]=temp; 3.[Sorted Values will be returned] A)Bubble Sort B)Quick Sort C)Selection Sort D)Merge Sort

3 Answers   Accenture,


write a program in c to find out the sum of digits of a number.but here is a condition that compiler sums the value from left to right....not right to left..

1 Answers  


Is fortran still used in 2018?

0 Answers  






Categories