Skip to content

Commit

Permalink
Merge pull request Anuja-19#40 from mansijain014/main
Browse files Browse the repository at this point in the history
Added C++ code for checking string palindrome
  • Loading branch information
Anuja-19 authored Oct 2, 2020
2 parents 3574228 + 8520893 commit 65f944c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Cpp/StringPalindrome.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>
#include <string.h>
using namespace std;

int main(){
char str[20];
int i,len;
int flag = 0;
cout << "Enter a string: ";
cin >> str;
len = strlen(str);

for(i=0;i<len;i++){
if(str[i] != str[len-i-1]){
flag = 1;
break;
}
}
if (flag) {
cout << str << " is not a palindrome" << endl;
}
else {
cout << str << " is a palindrome" << endl;
}
return 0;
}

0 comments on commit 65f944c

Please sign in to comment.