Computer Science, asked by neha1234551, 1 year ago

write a program to check the given number is palintron or not

Answers

Answered by BrainlyTech
2

\textbf{ Hello Friend! }

\textbf{ I'm here to write a program for you! }

\textbf{ Hope this will help you! }

\textbf{ Well I am a programmer so I know a lot about C++ }

\textbf{ So Lets Get Started! }

------------------------------------------------------------------------------

#include <stdio.h>

int main()

{

   int n, reversedInteger = 0, remainder, originalInteger;

   printf("Enter an integer: ");

   scanf("%d", &n);

   originalInteger = n;

   // reversed integer is stored in variable  

   while( n!=0 )

   {

       remainder = n%10;

       reversedInteger = reversedInteger*10 + remainder;

       n /= 10;

   }

   // palindrome if orignalInteger and reversedInteger are equal

   if (originalInteger == reversedInteger)

       printf("%d is a palindrome.", originalInteger);

   else

       printf("%d is not a palindrome.", originalInteger);

   

   return 0;

}

\textbf{ Hope This Helped You. }

\textbf{ If not let me know. }

\textbf{ If you need anymore help with your questions let me know }

\textbf{ Have A Good Day! }

\boxed{ Be Brainly Friend! }


devi9792: hii
devi9792: plz follow me
devi9792: plz plz plz
BrainlyTech: Sure why not
devi9792: Thanks for following me
BrainlyTech: No problem :)
devi9792: kk
neha1234532: please friends dont talk here please
devi9792: kk dear
BrainlyTech: @neha1234532 She asked me to do something so i did sorry.
Answered by stylishtamilachee
5

Correct Question:

Write a program to check whether the given number is a palindrome or not.

Answer:

import java.util.Scanner ;

public class Palindrome

{

public statis void main (String args[ ] )

{

Scanner sc = new Scanner (System.in) ;

System.out.print("Enter a number to be checked : ") ;

int number = sc.nextInt( ) ;

int reversedNumber = 0, temp = 0, savedNumber ;

savedNumber = number;

do {

temp = number % 10 ;

number = number / 10 ;

reversedNumber = reversedNumber * 10 + temp ;

} while (number! = 0) ;

if ( reversedNumber = = savedNumber)

System.out.println(savedNumber + "is a palindrome") ;

else

System.out.println(savedNumber + "not a palindrome") ;

}

}

Ouput:

Enter a number to be checked : 3003

3003 is a palindrome

Palindrome:

A palindrome reads the same from both sides,

Eg: 1331 is a palindrome number

Similar questions