write program for palindrome
Answer Posted / deepanjan
#include<stdio.h>
void main()
{
char ch[100];
int i,j,l,flag;
l=0;
flag=0;
printf("\n Enter to check if palindrome or not \n");
gets(ch);
for(i=0;ch[i]!='\0';i++)
{
l++;
}
for(i=0,j=l-1;i<(l/2)-1,j>(l/2);i++,j--)
{
if(ch[i]==ch[j])
flag=0;
else
{
flag=1;
break;
}
}
if(flag==0)
printf("\n Entered characters are palindrome");
else
printf("\n Entered characters are not a palindrome");
}
| Is This Answer Correct ? | 14 Yes | 15 No |
Post New Answer View All Answers
What is the difference between a template and a macro?
Explain linked list using c++ with an example?
What does new return if there is insufficient memory to make your new object?
Are vectors passed by reference c++?
Is c++ proprietary?
How do we balance an AVL Tree in C++?
What is an operator in c++?
What are the advantages of inheritance in c++?
How can a called function determine the number of arguments that have been passed to it?
What are the differences between malloc() and calloc()?
What are the storage qualifiers?
What is an iterator class in c++?
What is a local reference?
What is the use of main function in c++?
Explain the virtual inheritance in c++.