Answers for "palindrome number meaning"

1

palindrome number in java

import java.util.Scanner;

public class Palindrome
{
  public static void main(String args[])
  {
    int num,temp,reverse=0;
    Scanner input=new Scanner(System.in);
    num=in.nextInt();
    temp=num;
    //code to reverse the number
    while(temp!=0)
    {
      int d=temp%10; //extracts digit at the end
      reverse=reverse*10+d;
      temp/=10; //removes the digit at the end
    }
    // 'reverse' has the reverse version of the actual input, so we check
    if(reverse==num)
    {
      System.out.println("Number is palindrome");
    }
    else
    {
      System.out.println("Number is not palindrome");
    }
  }
}
Posted by: Guest on August-20-2020
1

palindrome number

while(n>0){    
   r=n%10;  //getting remainder  
   sum=(sum*10)+r;    
   n=n/10;    
  }
Posted by: Guest on June-08-2021
0

what is palindrome

function Palindrome(str) { 

  str = str.replace(/ /g,"").toLowerCase();
  var compareStr = str.split("").reverse().join("");

  if (compareStr === str) {
    return true;
  } 
  else {
    return false;
  } 

}
Posted by: Guest on June-17-2021
0

palindrome no example

171, 181, 191, 202
Posted by: Guest on June-04-2021
0

palindrome

#include<iostream>
#include<string>
#include<algorithm>
bool IsPalindrome_true_false(const std::string& );

int main ()
{
    
    std::cout<<"Please enter a string:\t";
    std::string str;
    getline(std::cin, str);
    
    // convert the string from uppercase to lowercase 
    int i = 0;
    while(str[i])
    {
        if(str[i] == std::toupper(str[i]) && std::isalpha(str[i]) == 1024)
        str[i]+= 32;
        ++i;
    }
    // looping while string is empty 
    while(str.empty())
    {
        std::cout<<"\nPlease enter a string your string is empty:\t";
        if(!str.empty())
        std::string str;
        getline(std::cin, str);
    }
    
    std::cout<<"\n"<<std::boolalpha<<IsPalindrome_true_false(str)<<std::endl;
    std::cout<<std::endl;

    return 0;
}

// check if string is a palindrome and return true or false 
bool IsPalindrome_true_false(const std::string& str)
{

    int i = 0;                
    int j = str.length() - 1; 

    while(i <= j )
    {   
        
        if(std::isalpha(str[i]) == 0){
            ++i;
            continue;
        }else if(std::isalpha(str[j]) == 0){
            --j;
            continue;
        }   
        if(str[i] != str[j]){
        
           return false;
        }
        ++i;
        --j;
    }  
    return true;
}
Posted by: Guest on January-02-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language