write a program to find the given number is a palindromic number or not. it is a number that reads same from both direction. ex:- 121,3223
Answers
Answer:
C Program to Check Whether a Number is Palindrome or Not
In this example, you will learn to check whether the number entered by the user is a palindrome or not.
To understand this example, you should have the knowledge of the following C programming topics:
C Programming Operators
C if...else Statement
C while and do...while Loop
An integer is a palindrome if the reverse of that number is equal to the original number.
Program to Check Palindrome
#include <stdio.h>
int main() {
int n, reversedN = 0, remainder, originalN;
printf("Enter an integer: ");
scanf("%d", &n);
originalN = n;
// reversed integer is stored in reversedN
while (n != 0) {
remainder = n % 10;
reversedN = reversedN * 10 + remainder;
n /= 10;
}
// palindrome if orignalN and reversedN are equal
if (originalN == reversedN)
printf("%d is a palindrome.", originalN);
else
printf("%d is not a palindrome.", originalN);
return 0;
}
Output
Enter an integer: 1001
1001 is a palindrome.
Hope this is helpful to you......
Please follow me
And mark this as Brainliest PLEASE
Brainliest PLEASE
Brainliest PLEASE
Brainliest PLEASE
Question:-
Write a program to find whether a given number is palindrome or not. A number is said to be a Palindrome number if it reads same from both directions. For example, 121,1331,14641 and so on.
Code:-
Here is the code given below.
import java.util.*;
class Palindrome
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter an integer number: ");
int n=sc.nextInt();
n=Math.abs(n);
int m=n;
int s=0;
while(m!=0)
{
int d=m%10;
s=s*10+d;
m/=10;
}
if(s==n)
System.out.println("Number is a palindrome number.");
else
System.out.println("Number is not a palindrome number.");
}
}