How to check whether string is a palindrome, WITHOUT USING
STRING FUNCTIONS?

Answers were Sorted based on User's Feedback



How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?..

Answer / ramu gurram

#include<stdio.h>
void main()
{
char str[10]="liril";
int i,l,count=1;
printf("first find the string length as follow\n");
printf("\n\n");
for(l=0;str[l]!='\0';l++)
{
}
printf("length of the string %s is %d\n",str,l);
printf("\n\n");
for(i=0,l=l-1;l>=0;l--,i++)
{
if(str[i]!=str[l])
{
count++;
break;
}
}
if(count==1)
printf("given string is palindrom");
else
printf("given string is not palindrom");
}

Is This Answer Correct ?    20 Yes 4 No

How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?..

Answer / narasimharao

#include<stdio.h>
#include<conio.h>
void main()
{
char str[20]="malayalam",str1[20];
int i,j,k,c;
clrscr();
for(c=0;str[c]!='\0';c++)
{
}
printf("%d\n",c);
for(i=c-1,j=0;i>=0;i--,j++)
{
str1[j]=str[i];
}
printf("%s\n",str1);
k=1;
for(i=0;str[i]!='\0';i++)
{
if(str[i]!=str1[i])
{
k=0;
break;
}
}
if(k==1)
printf("Given String is Palindrome");
else
printf("Given String is Not Palindrome");
getch();
}

Is This Answer Correct ?    10 Yes 8 No

Post New Answer

More C Interview Questions

input may any number except 1,output will always 1.. conditions only one variable should be declare,don't use operators,expressions,array,structure

4 Answers   IBM,


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database

2 Answers   TCS, Unisys, Webyog,


# define x=1+4; main() { int x; printf("%d%d",x/2,x/4); }

5 Answers  


write a program to print %d ?

12 Answers  


Why we use int main and void main?

0 Answers  


What is the scope of global variable in c?

0 Answers  


what do structure language means?

3 Answers   Microsoft,


What is conio h in c?

0 Answers  


What is the c language function prototype?

0 Answers  


In C language what is a 'dangling pointer'?

0 Answers   Accenture,


Why doesn't the code "a[i] = i++;" work?

4 Answers  


main() { int arr[5]={23,67}; printf("%d%d%d",arr[2],arr[3],arr[4]); }

9 Answers   TCS,


Categories