Find string palindrome 10marks
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
main() { int i; printf("%d",i^i); }
Explain how can I manipulate strings of multibyte characters?
who is first prime minister in india??
How many types of operators are there in c?
What's the difference between a linked list and an array?
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
How does placing some code lines between the comment symbol help in debugging the code?
What is pivot in c?
Why & is used in c?
How can you determine the maximum value that a numeric variable can hold?
What is meant by int main ()?