Write a code to check a palindrome.

AnswerBot
1y

Code to check if a given string is a palindrome or not.

  • Remove all non-alphanumeric characters from the string

  • Convert the string to lowercase

  • Reverse the string and compare with the original string

  • If th...read more

itsClaw
1y

# Take user input

user_input = input('Enter a character or number: ')

# Reverse the input

reversed_input = user_input[-1::-1]

# Check for palindrome

if user_input == reversed_input:

print('It is a palindro...read more

Komal Goswami
1y

import java.util.*;

class PalindromeExample2

{

public static void main(String args[])

{

String original, reverse = ""; // Objects of String class

Scanner in = new Scanner(System.in);

System.out.println("Enter a string/number to check if it is a palindrome");

original = in.nextLine();

int length = original.length();

for ( int i = length - 1; i >= 0; i-- )

reverse = reverse + original.charAt(i);

if (original.equals(reverse))

System.out.println("Entered string/number is a palindrome.");

else

System.out.println("Entered string/number isn't a palindrome.");

}

}

Kasi Pasalapudi1234
1y

#include<stdio.h>

int main(){

int a, temp;

scanf("%d",&a);

temp=a;

int rev=0;

while(a>0){

rev=(rev*10)+(a%10);

a=a/10;

}

if(rev==temp){

printf("palindrome");

}

else{

printf("Not a palindrome");

}

retur...read more

Kasi Pasalapudi1234
1y

#include<stdio.h>

int main(){

int a, temp;

scanf("%d",&a);

temp=a;

int rev=0;

while(a>0){

rev=(rev*10)+(a%10);

a=a/10;

}

if(rev==temp){

printf("palindrome");

}

else{

printf("Not a palindrome");

}

retur...read more

Kasi Pasalapudi1234
1y

#include<stdio.h>

int main(){

int a, temp;

scanf("%d",&a);

temp=a;

int rev=0;

while(a>0){

rev=(rev*10)+(a%10);

a=a/10;

}

if(rev==temp){

printf("palindrome");

}

else{

printf("Not a palindrome");

}

retur...read more

Samadhan Gandole
2y

Class palindrome number {

Public Static void main (String []args)

{

int No=123,rev=0,rem,temp=No;

While(No>0)

{

rem=No%10;

rev=rev*10+rem;

No=No/10;

}

If(temp==rev)

System.out.println("Palindrome number");

Else

Sy...read more

Add answer anonymously...
EY Global Delivery Services ( EY GDS) Technology Consultant Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter