write program for palindrome

Answer Posted / mojib khan

#include<stdio.h>

void main()
{
int i=0,l,flag=0;
char str[30];
clrscr();
printf("Enter the string\n");
gets(str);
l=strlen(str)-1;
while(i<=l)
{
if(str[i]==str[l])
flag=1;
else
{
flag=0;
break;
}
i++;
l--;
}
if(flag==1)
printf("String is palindrom");
else
printf("\n String is not palindrom");
getch();
}

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does the linker do?

584


Define pre-condition and post-condition to a member function in c++?

654


What is encapsulation in C++? Give an example.

582


Is there any difference between int [] a and int a [] in c++?

543


Is c++ a software?

719






What is a singleton c++?

543


What is private, public and protected inheritance?

583


What is the difference between #import and #include in c++?

590


What are the advantages of using typedef in a program?

632


Explain Memory Allocation in C/C++ ?

627


Can a constructor return a value?

570


How can you say that a template is better than a base class?

578


Explain selection sorting. Also write an example.

577


What are virtual constructors/destructors?

571


Explain what is polymorphism in c++?

621