Thursday, 19 November 2020

Write a Program in C++ to accept a word and check whether it is Palindrome or not. (Without ignoring the case)

#include<iostream>

using namespace std;

main()

{

  string s,rev=""; int i, len;

  cout<<"Enter a Word\n";

  cin>>s;

  len=s.length()-1;

  for(i=len;i>=0;i--)

  {

   rev=rev+s.at(i);

  }

  if(rev==s)

    cout<<s<<" is a Palindrome Word";

  else

     cout<<s<<" is not a Palindrome Word";

 }

No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...