Write code to check if a string is a palindrome.

AnswerBot
2y

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
2y

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
2y

#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
2y

#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
2y

#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

Select
Add answer anonymously...

Popular interview questions of Technology Consultant

A Technology Consultant was asked Q1. What is the difference between single variant and multivariant parameters?
A Technology Consultant was asked Q2. Write code to check if a string is a palindrome.
A Technology Consultant was asked Q3. Why do we need IPv6 if we already have IPv4?
EY Global Delivery Services ( EY GDS) Technology Consultant Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits