i am trying to find out weather the entered string is palindrome or not ,but this code isn't giving the correct output. | SoloLearn: Learn to code for FREE!

+1

i am trying to find out weather the entered string is palindrome or not ,but this code isn't giving the correct output.

#include <iostream> using namespace std; string isPalindrome(string s, int n) { int i=0; for(;i<n;i++) { if(s[i]==s[n-i-1]) continue; else return "No"; } return "Yes"; } int main() { //code int n; // size of the string cin >>n; string s; // cin >> s; cout << isPalindrome(s,n) << endl; return 0; }

5/23/2020 12:12:15 PM

SHIVANSHU BAJPAI

2 Answers

New Answer

+1

Inputs: 5 12721 Works fine Edit: else{ return "No"; break; }

0

Try to enter a non palindrome string