Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to check string is palindrome or not by user input using c or c++

#include <bits/stdc++.h>

using namespace std;

int main(){
    string s;
    cin >> s;
    
    int l = 0;
    int h = s.length()-1;

    while(h > l){
        if(s[l++] == s[h--]){
            cout << "Not a palindrome" << endl;
            return 0;
        }
    }
    cout << "Is a palindrome" << endl;
    return 0;

}
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #check #string #palindrome #user #input
ADD COMMENT
Topic
Name
5+9 =