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

What is structure in c explain with example?

0 Answers  


all c language question

0 Answers   Wipro,


void main() { for(; 0 ;) ... { printf("hello"); ... } getch(); }

1 Answers  


x=y=z=1 z=++x||++y&&++z Printf("%%%d";xyz) what is the values of x,y and z?????

3 Answers  


WHAT IS INT?

8 Answers   Accenture,






Do you know what are the properties of union in c?

0 Answers  


write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3

0 Answers   ADP,


Explain can the sizeof operator be used to tell the size of an array passed to a function?

0 Answers  


What are the advantages of external class?

0 Answers  


what are the stages of compilation

1 Answers   Bosch,


can u suggest me am in a confusion to choose whether to go to c programming or a software testing . am a graduate in B.sc(electronics).

1 Answers  


What is the o/p of the follow pgm? #include<stdio.h> main() { char char_arr[5]=”ORACL”; char c=’E’; prinf(“%s\n”,strcat(char_arr,c)); } a:oracle b. oracl c.e d.none

2 Answers   Oracle,


Categories