Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ check palindrome

#include<iostream>
#include<ctype.h>
using namespace std;
int main() {
	string s; cin >> s;
	int a = 0;
	for(int i = 0; i < (s.length() / 2); i++) 
		if(s[i] == s[s.length() - 1 - i]) a++;
	if(a == (s.length() / 2)) cout << "YES";
	else cout << "NO";
	return 0;
}
Comment

check if a string is palindrome cpp

// Check whether the string is a palindrome or not.
#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;

}
Comment

palindrome program in c++

#include <iostream>


bool isPalindrome (int number) {
    int decomposed = number, reversed = 0;
    while (decomposed) {
        reversed = 10 * reversed + (decomposed % 10);
        decomposed /= 10;
    }
    return reversed == number;
}
Comment

palindrome checker in c++

#include<iostream>
using namespace std;

int main()
{
	string s1, s2;
	cout << "Enter string: ";
	cin >> s1;

	for (int i = s1.length()-1; i >= 0; i--)
	{
		s2 += s1[i];
	}

	if (s1 == s2)
	{
		cout << "Palindrome!" << endl;
	}
	else
	{
		cout << "Not Palindrome!" << endl;
	}

	return 0;
}
Comment

Palindrome String solution in c++

class Solution{
public:	
	
	
	int isPalindrome(string S)
	{
	    // Your code goes here
        int n=S.length();
        for(int i=0;i<n/2;i++)
        {
            if(S[i]!=S[n-1-i])
            {
                return 0;
            }
        }
        return 1;
	}

};
Comment

PREVIOUS NEXT
Code Example
Cpp :: binary representation c++ 
Cpp :: hamming distance c++ 
Cpp :: sort 0 1 2 leetcode 
Cpp :: time_t to int 
Cpp :: how to get the type of a variable in c++ 
Cpp :: C++ structure (Struct) 
Cpp :: c++ get string between two characters 
Cpp :: c++ Sum of all the factors of a number 
Cpp :: run cmd command c++ 
Cpp :: cstring to string 
Cpp :: c++ pi float 
Cpp :: how to find the size of a character array in c++ 
Cpp :: c++ string size 
Cpp :: how to input a vector when size is unknown 
Cpp :: sizeof operator in c++ 
Cpp :: quick sort c+++ 
Cpp :: memmove 
Cpp :: string split by space c++ 
Cpp :: c++ filesystem read directory 
Cpp :: c++ 14 for sublime windoes build system 
Cpp :: if statement c++ 
Cpp :: opengl draw semi circle c++ 
Cpp :: what is meant by pragma once in c++ 
Cpp :: gcc suppress warning inline 
Cpp :: c++ pre-processor instructions 
Cpp :: vector of vectors of pairs c++ 
Cpp :: map count function c++ 
Cpp :: how to have a queue as a parameter in c++ 
Cpp :: how to grab numbers from string in cpp 
Cpp :: c++ std string to float 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =