DESCRIPTION-:THIS PROGRAM CHECKS WHETHER THE ENTERED NUMBER IS PALINDROME
OR NOT.PALINDROME NUMBER IS ONE WHOSE REVERSE IS SAME AS THAT
OF ENTERED GIVEN NUMBER.NOT
THIS PROGRAM FIRST CALCULATE THE REVERSE OF THE GIVEN NUMBER AND THEN CHECK WHETHER THE REVERSE OF NUMBER IS EQUAL TO THE ENTERED NUMBER,IF BOTH NUMBERS ARE SAME THEN THE ENTERED NUMBER IS PALINDROME ELSE.
FOR EXAMPLE-: IF WE ENTER ELEMENT AS--------
123
THEN IT GENERATE OUTPUT AS---------
THE NUMBER IS NOT PALINDROME
PROGRAM-:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,m,i,rem,rev=0;
cout<<"enter the required number";
cin>>n;
m=n;
while(m>0)
{
rem=m%10;
m=m/10;
rev=rev*10+rem;
}
cout<<"reverse of number is"<<rev<<"\n";
if(rev==n)
{
cout<<"number is palindrome";
}
else
{
cout<<"number is not palindrome";
}
getch();
}
OR NOT.PALINDROME NUMBER IS ONE WHOSE REVERSE IS SAME AS THAT
OF ENTERED GIVEN NUMBER.NOT
THIS PROGRAM FIRST CALCULATE THE REVERSE OF THE GIVEN NUMBER AND THEN CHECK WHETHER THE REVERSE OF NUMBER IS EQUAL TO THE ENTERED NUMBER,IF BOTH NUMBERS ARE SAME THEN THE ENTERED NUMBER IS PALINDROME ELSE.
FOR EXAMPLE-: IF WE ENTER ELEMENT AS--------
123
THEN IT GENERATE OUTPUT AS---------
THE NUMBER IS NOT PALINDROME
PROGRAM-:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,m,i,rem,rev=0;
cout<<"enter the required number";
cin>>n;
m=n;
while(m>0)
{
rem=m%10;
m=m/10;
rev=rev*10+rem;
}
cout<<"reverse of number is"<<rev<<"\n";
if(rev==n)
{
cout<<"number is palindrome";
}
else
{
cout<<"number is not palindrome";
}
getch();
}
0 comments:
Post a Comment