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 right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
write a program to reverse the words in the sentence.NOTE:not reverse the entire string but just the occurance of each word
Write any data structure program (stack implementation)
find the output of the following program main() { int x=5, *p; p=&x; printf("%d",++*p); }
#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }
Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
5 Answers TCS, Vimukti Technologies,
Find if a number is power of two or not?
What are reserved words with a programming language?
What is the purpose of the statement: strcat (S2, S1)?
what is use#in c
how to find that no is int or float?
Which command is more efficient? *(ptr+1) or ptr[1]