-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path03.cpp
More file actions
38 lines (38 loc) · 675 Bytes
/
Copy path03.cpp
File metadata and controls
38 lines (38 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<iostream>
using namespace std;
int Reverse(int n)
{
int temp=0;
while(n!=0)
{
temp += n%10;
if(n/10!=0)
{
temp=temp*10;
}
n=n/10;
}
return temp;
}
bool checkPalindrome(int i)
{
bool flag=true;
int rev = Reverse(i);
if(rev!=i)
flag=false;
return flag;
}
int main()
{
//palindrome numbers : which reads same backwards as forward
//printing palindrome numbers under 1000
for(int i=0;i<1000;i++)
{
bool c = checkPalindrome(i);
if(c==true)
{
cout<<i<<" ";
}
}
return 0;
}