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 malloc in c++?
Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
Do we have to use initialization list in spite of the assignment in constructors?
Write a short code using c++ to print out all odd number from 1 to 100 using a for loop
What is the best free c++ compiler for windows?
What is the main purpose of overloading operators?
What is pair in c++?
What is the difference between while and do while loop? Explain with examples.
What is #include cmath?
Explain virtual class?
Explain queue. How it can be implemented?
Write a program using display() function which takes two arguments.
What are destructors?
What is the basic difference between C and C++?
Write a program using shift_half( ) function to shift the elements of first half array to second half and vice versa.