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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Is there a way to switch on strings?

623


How can I do serial ("comm") port I/O?

696


What are local static variables? How can you use them?

651


What is a struct c#?

607


What is substring in c?

645






What are disadvantages of C language.

652


Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

2061


any "C" function by default returns an a) int value b) float value c) char value d) a & b

673


An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above

710


Can we declare variables anywhere in c?

584


Is c high or low level?

590


Difference between Shallow copy and Deep copy?

1576


ATM machine and railway reservation class/object diagram

4807


What is the advantage of an array over individual variables?

748


If you know then define #pragma?

679