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


Please Help Members By Posting Answers For Below Questions

What is c++ runtime?

663


Write a program using display() function which takes two arguments.

620


How long it will take to learn c++?

622


What is late binding c++?

551


Explain how the virtual base class is different from the conventional base classes of the opps.

712






What does new do in c++?

645


What is the first name of c++?

571


Define virtual constructor.

653


What relational operators if statements in c++?

653


Describe linked list using C++ with an example.

663


How can you prevent accessing of the private parts of my class by other programmers (violating encapsulation)?

650


Differentiate between late binding and early binding.

656


What is the meaning of c++?

558


What is the use of string in c++?

559


what are the events occur in intr activated on interrupt vector table

1188