A special site for solving fun programming problems and challenges, interested in computer science, programming, basics, data structure and algorithms

 palindrome checker in cpp:

——————————————

  1. #include<iostream> 
  2. using namespace std; 
  3.  
  4. int main() 
  5. { 
  6. string s1, s2; 
  7. cout << "Enter string: "; 
  8. cin >> s1; 
  9.  
  10. for (int i = s1.length()-1; i >= 0; i--) 
  11. { 
  12. s2 += s1[i]; 
  13. } 
  14.  
  15. if (s1 == s2) 
  16. { 
  17. cout << "Palindrome!" << endl; 
  18. } 
  19. else 
  20. { 
  21. cout << "Not Palindrome!" << endl; 
  22. } 
  23.  
  24. return 0; 
  25. } 

——————————————

https://onlinegdb.com/s4TYazCKw

——————————————


No comments:

Post a Comment