Find string palindrome 10marks
Answer Posted / abdur rab
#include <stdio.h>
int isPalindrome ( char* str, int nLength )
{
if ( nLength < 1 ) return ( 1 );
if ( str [0] == str [ nLength -1 ] ) return (
isPalindrome ( ( str + 1 ) , ( nLength - 2 ) ) );
else return ( 0 );
}
int main (int argc, char* argv[])
{
char a[10] = {"ropepor"};
if ( isPalindrome ( a, strlen ( a ) ) ) printf
("\n The string is Palindrome");
else printf ("\n The string is NOT Palindrome");
return (1 );
| Is This Answer Correct ? | 7 Yes | 3 No |
Post New Answer View All Answers
What is a void pointer? When is a void pointer used?
How can I do peek and poke in c?
What does 2n 4c mean?
What are the advantages and disadvantages of a heap?
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
Can we replace the struct function in tree syntax with a union?
Why doesnt that code work?
Can math operations be performed on a void pointer?
What is a rvalue?
Why c is procedure oriented?
Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.
How main function is called in c?
What's the difference between constant char *p and char * constant p?
Is c# a good language?
What is console in c language?