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 |
What is the description for syntax errors?
Why double pointer is used in c?
#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b); }
What is a const pointer in c?
What is the relationship between pointers and data structure?
what is the most appropriate way to write a multi-statement macro?
How can I get random integers in a certain range?
Can we assign integer value to char in c?
How will you delete a node in DLL?
What is difference between far and near pointers?
Suggesting that there can be 62 seconds in a minute?
How to print all the 26 alphabets in this order in C. AbCdEfGh..... it should print dynamically from a to z and do not print this using pgm like this print("Ab......"); Use loops or anything to print all alphabets