This Post Contains A C++ Program To Check Whether The User Entered Integer Is Palindrome With Correct Source Code, Algorithm & Output. This Program Is Written, Compiled & Executed At TurboC/C++3.0 Compiler & Will Help You To Understand The Concept Of 'While-Loop' & 'If...else' From C++ Language. It Is A Well-Structured Program With Proper Comments Which Provides Step-By-Step Description Of Various Features Of The Language In A Simple & Easy-To-Understand Way.
# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.
C++ Program To Check Whether The User Entered Integer Is Palindrome Or Not.
/* Declaration Of Header Files */
#include<iostream.h>
#include<conio.h>
/* Start Of Main Program */
void main()
{
/* Declaration Of Variables */
int Num, Rem=0, Quo=0, temp=0;
clrscr();
/* Asking For The Input From User */
cout<<" \n Please Enter A Number : ";
cin>>Num;
/* Source Code For Checking Integer As Palindrome */
Quo=Num;
while(Quo!=0)
{
Rem = Quo % 10;
temp = (temp*10) + Rem;
Quo = Quo / 10;
}
if(Num==temp)
{
cout<<" \n The Number "<<Num<<" Is Palindrome ";
}
else
{
cout<<" \n The Number "<<Num<<" Is Not Palindrome ";
}
getch();
}
/* End Of Main Program */
Output :
Please Enter A Number : 11
The Number 11 Is Palindrome
Please Enter A Number : 21
The Number 21 Is Not Palindrome
# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.
C++ Program To Check Whether The User Entered Integer Is Palindrome Or Not.
/* Declaration Of Header Files */
#include<iostream.h>
#include<conio.h>
/* Start Of Main Program */
void main()
{
/* Declaration Of Variables */
int Num, Rem=0, Quo=0, temp=0;
clrscr();
/* Asking For The Input From User */
cout<<" \n Please Enter A Number : ";
cin>>Num;
/* Source Code For Checking Integer As Palindrome */
Quo=Num;
while(Quo!=0)
{
Rem = Quo % 10;
temp = (temp*10) + Rem;
Quo = Quo / 10;
}
if(Num==temp)
{
cout<<" \n The Number "<<Num<<" Is Palindrome ";
}
else
{
cout<<" \n The Number "<<Num<<" Is Not Palindrome ";
}
getch();
}
/* End Of Main Program */
Output :
Please Enter A Number : 11
The Number 11 Is Palindrome
Please Enter A Number : 21
The Number 21 Is Not Palindrome
No comments:
Post a Comment