Interview Questions   Tutorials   Discussions   Programs   Videos   

C++ - Write program for palindrome?




318
views
asked marvit August 18, 2014 11:59 AM  

Write program for palindrome?


           

1 Answers



 
answered By bhjahnavi   0  
palindrome  is if we read the string from right to left or left to right the string appears the same

/*program to find whether the given string is palindrome or not*/
#include<iostream.h>
#include<conio.h>
int main( )
{
	clrscr( );
	char str[80];
	cout<<"Enter a string:";
	gets(str);

	for(int L=0;str[L]!='\0';L++);		

	for(int C=0;(C<L/2) && (str[C]==str[L-C-1]);C++);

	if(C==L/2)
		cout<<"Palindrome";
	else
		cout<<"Not a palindrome";

	getch();
	return 0;
} 
flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert