A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

WAP to calculate the palindrome in c++

#include<iostream>
using namespace std;
int main()
{

//define all variables  and take flag=1
char s[10],c;
int i,j,flag=1,len;

//eneter values using getline()
cout<<"enter string(max.8):";
cin.getline(s,10);

//FOR find the length of string
for( len=0;s[len]!='\0';len++);

//checking char
for(i = 0,j = len-1;i<len/2;i++,j--)
{
 if(s[i]!=s[j])
 {
  flag=0;
  break;
 }
}
 if(flag!=0) //if flag is true.
 cout<<"it is a palindrome.\n";
 else
 cout<<"it is not a palindrome.\n";
}













LEARN TUTORIALS

.

.