Tuesday, 17 November 2020

C++ Program to accept a Number and check whether it is Palindrome or not.

/* A palindrome number is a number that is same after reverse. For example 545, 151, 34543, 343, 171, 48984 are the palindrome numbers. */

#include <iostream>

using namespace std;

int main()

{
int N,r=0,d,Num;
cout<<"Enter a Number to check whether it is Palindrome or not\n";
cin>>N;
Num=N;
while(N>0)
{
d=N%10;
r=r*10+d;
N=N/10;
}
if(r==Num)
cout<<Num<<" is a Palindrome Number";
else
cout<<Num<<" is not a Palindrome Number";
}

No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...