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
How is pointer initialized in c?
What is the difference between declaring a variable and defining a variable?
What is calloc() function?
Explain do array subscripts always start with zero?
What do you mean by keywords in c?
What is the meaning of c in c language?
Find MAXIMUM of three distinct integers using a single C statement
What is the heap?
What is the maximum length of an identifier?
What is substring in c?
What are directives in c?
What is use of null pointer in c?
Differentiate between the = symbol and == symbol?
What is the purpose of clrscr () printf () and getch ()?
Can we compile a program without main() function?