Search
 
SCRIPT & CODE EXAMPLE
 

CPP

pallindrome string

#include <iostream>
using namespace std;

bool isPalindrome(string str)
{
    int j = str.length() - 1;

    for (int i = 0; i < j; i++, j--)
    {
        if (str[i] != str[j])
        {
            return false;
        }
    }

    return true;
}

int main()
{
    string words[5] = {"mom", "radar", "level", "hello", "one"};
    for (int i = 0; i < 5; i++)
    {
        if (isPalindrome(words[i]))
        {
            cout << words[i] << " -> Palindrome" << endl;
        }
        else
        {
            cout << words[i] << " -> Not a Palindrome" << endl;
        }
    }

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: decemal representation 
Cpp :: c to c++ code converter 
Cpp :: c++ Testing implementation details for automated assessment of sorting algorithms 
Cpp :: Types of Conversions- C++ 
Cpp :: KL/wweiok#L['.[- 
Cpp :: reading matrix from text file in c++ and adding them and then storing them in oother c++ file 
Cpp :: c plus 
Cpp :: ternary operator rsut 
Cpp :: Link List Insertion a node 
Cpp :: c++ program that put a space in between characters 
Cpp :: Create an algorithm to identify what is the next largest element on a stack (using stack/queue operations only) INPUT: [ 10, 3, 1, 14, 15, 5 ] OUTPUT: 10 - 14 3 - 14 1 - 14 14 - 15 15 - -1 5 - -1 
Cpp :: Nested ternary operator C++ 
Cpp :: stack algorithm in c++ 
Cpp :: pagesNumbering C++ 
Cpp :: c++ arrays 
Cpp :: convert java to c++ 
Cpp :: DMA c/c++ 
Cpp :: converting a string to lowercase inbuld function in cpp 
Cpp :: check if a variable is tring c++ 
Cpp :: inorder to postorder converter online 
Cpp :: vector stop at newline 
Cpp :: Make them equal codechef solution in c++ 
Cpp :: how to read and write to a file in qt c++ 
Cpp :: run a c++ file in terminal 
Cpp :: decising how many numbers after comma c++ 
Cpp :: 16630147 
Cpp :: add comment in c/c++ 
Cpp :: cpp qmenu add custom widget action 
Cpp :: how to use and in c++ 
Cpp :: return value optimization example 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =