Find string palindrome 10marks

Answers were Sorted based on User's Feedback



Find string palindrome 10marks ..

Answer / coolcom(chandan)

void main()
{
int a,len,palin;
char s[20];

scanf("%s",s);

len=strlen(s);
printf("%d \n",len);

for(a=0,len=len-1;a<len;a++,len--)
{
palin=0;
if(s[a]==s[len])
palin=1;

else
{
printf("string %s is not palindrome",s);
getch();
exit();
}
}
printf("string %s is palindrome",s);
getch();

}

Is This Answer Correct ?    11 Yes 0 No

Find string palindrome 10marks ..

Answer / babitha

void main()
{
int a,len,palin;
char s[20];

scanf("%s",s);

len=strlen(s);
printf("%d \n",len);

for(a=0,len=len-1;a<len;a++,len--)
{
if(s[a]==s[len])
palin=1;

else
break;
}

if(palin==1)
printf("string %s is palindrome",s);
else
printf("string %s is not palindrome",s);

getch();

}

Is This Answer Correct ?    18 Yes 10 No

Find string palindrome 10marks ..

Answer / 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

Find string palindrome 10marks ..

Answer / vivek

bool
IsPalindrome( char *lpStr )
{
int n,i;
n = strlen( lpStr );
for ( i = 0; i < n/2; i++ )
{
if ( lpStr[i] != lpStr[n-i-1] )
{
return FALSE;
}
}
return TRUE;
}

Is This Answer Correct ?    5 Yes 2 No

Find string palindrome 10marks ..

Answer / abhilash meda

#include"string.h"
void main()
{
char *str,*rev;
int i,j;
clrscr();
printf("\nEnter a string:");
scanf("%s",str);
for(i=strlen(str)-1,j=0;i>=0;i--,j++)
rev[j]=str[i];
rev[j]='\0';
if(strcmp(rev,str))
printf("\nThe string is not a palindrome");
else
printf("\nThe string is a palindrome");
getch();
}

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More C Interview Questions

main() { int i; printf("%d",i^i); }

1 Answers  


Explain how can I manipulate strings of multibyte characters?

0 Answers  


who is first prime minister in india??

8 Answers   Wipro,


How many types of operators are there in c?

0 Answers  


What's the difference between a linked list and an array?

14 Answers  






Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

0 Answers  


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

0 Answers  


How does placing some code lines between the comment symbol help in debugging the code?

0 Answers  


What is pivot in c?

0 Answers  


Why & is used in c?

0 Answers  


How can you determine the maximum value that a numeric variable can hold?

0 Answers  


What is meant by int main ()?

0 Answers  


Categories