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

How can I find the modification date of a file?

0 Answers   Celstream,


How many types of operators are there in c?

0 Answers  


What is the difference between scanf and fscanf?

0 Answers  


You have an int array with n elements and a structure with three int members. ie struct No { unsigned int no1; unsigned int no2; unsigned int no3; }; Point1.Lets say 1 byte in the array element is represented like this - 1st 3 bits from LSB is one number, next 2 bits are 2nd no and last 3 bits are 3rd no. Now write a function, struct No* ExtractNos(unsigned int *, int count) which extracts each byte from array and converts LSByte in the order mentioned in point1.and save it the structure no1, no2, no3. in the function struct No* ExtractNos(unsigned int *, int count), first parameter points to the base address of array and second parameter says the no of elements in the array. For example: if your array LSB is Hex F7 then result no1 = 7, no2 = 2, no3 = 7. In the same way convert all the elements from the array and save the result in array of structure.

2 Answers   Qualcomm,


without a terminator how can we print a message in a printf () function.

7 Answers   NIIT,






Difference between linking and loading?

0 Answers  


Explain what is a 'locale'?

0 Answers  


Function shall sum members of given one-dimensional array. However, it should sum only members whose number of ones in the binary representation is higher than defined threshold (e.g. if the threshold is 4, number 255 will be counted and 15 will not) - The array length is arbitrary - output the results to the stdout

0 Answers   XYZ,


Explain what is a pragma?

0 Answers  


write a c program to remove all the duplicate characters in a string and replace with single character? ex:-input- AAABBBCCC output- ABC

2 Answers   HCL,


what is the output of below int n=10; (n++)++; printf("%d",n);

3 Answers  


Can you subtract pointers from each other? Why would you?

0 Answers  


Categories