Computer Science, asked by amishatickoo26, 1 year ago

. Write a program to input a string. If the string is a palindrome then concatenate “Hello Palindrome “, otherwise concatenate “Hello Non- palindrome “ with the given string. Then display the resultant string

Answers

Answered by Arslankincsem
1

This type of programme can be made in C++ using String manipulation techniques.

The C-type character string started with the C language and it continues to be there in C++.

The C-string is basically a one-dimensional character array that is terminated using a null character '\0'.

Therefore, a null-terminated string, '\0', has all the characters that includes the string and suffixed by a null.

Answered by vikramqcet
1

Answer:

#include <iostream>

using namespace std;

int main(){

   char string1[20];

   int i, length;

   int flag = 0;

   

   cout << "Enter a string: "; cin >> string1;

   

   length = strlen(string1);

   

   for(i=0;i < length ;i++){

       if(string1[i] != string1[length-i-1]){

           flag = 1;

           break;

  }

}

   

   if (flag) {

       cout << string1 << " is not a palindrome" << endl;  

   }    

   else {

       cout << string1 << " is a palindrome" << endl;  

   }

   system("pause");

   return 0;

}

Explanation:

Similar questions