Answer to Question #163257 in C++ for zain ul abdeen

Question #163257

Write a program, which takes an array of characters from users. Your task is to check either it is palindrome or not.


Note: Palindrome is a string that reads the same from both ends. i.e. bob, mom, dad, civic.


1
Expert's answer
2021-02-12T18:16:48-0500
#include<iostream>
using namespace std;


void palindromTest(char array[],int n){
int flag=0;
for(int k=0;k<=n/2&&n!=0;k++){
    if(array[k]!=array[n-k-1]){
        flag=1;
        break;
    }
    if (flag == 1)
        cout << "Not Palindrome";
    else
        cout << "Palindrome";

}

}
int main(){
int n;
char array[n];
cout<<"Number of elements are present in the array:\n"<<endl;
cin>>n;
cout<<"\n Total number of elements present in the array\n"<<n<<endl;
cout<<"Please enter the letters of english word(english word)"<<endl;
for (int i = 0; i < n; i++) {
        cin >> array[n];
    }
cout << "The entered word is: ";

    for (int j = 0; j < n; ++j) {
        cout <<array[n];
    }

    palindromTest(array,n);
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment