Program To Check Whether a Number is a Palindrome or not.

#include<iostream>
using namespace std;
int main()
{
int n,num,digit,rev=0;
cout<<"Enter a positive number:";
cin>>num;
n=num;
do{
digit=num%10;
rev=(rev*10)+digit;
num=num/10;
}
while (num!=0);
cout<<"The reverse of the number is :"<<rev<<endl;
if(n==rev)
cout<<"The number is palindrome\n\n";
else
cout<<"The number is not a palindrome\n\n";
cout<<"/*\nName-Sanjampreet Singh\nRoll Number-1507967\n*/";
}

Output:

Comments

Popular posts from this blog

To create an html page with frames and frameset

1. Write a program to insert a new element at end as well as at a given position in an array in Java

1. To familiarize with network devices like switch, hub, routers and bridges in LaTex