Skip to content

Commit 6daec1e

Browse files
authored
Create palindrome.c
Program to find a given integer is palindrome or not.
1 parent c9fb36e commit 6daec1e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

c/palindrome.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <stdio.h>
2+
#include <conio.h>
3+
int reverse(int num);
4+
int p_d(int num);
5+
int main()
6+
{
7+
int num;
8+
printf("Number:");
9+
scanf("%d", &num);
10+
if(p_d(num) == 1)
11+
{
12+
printf("Palindrome");
13+
}
14+
else
15+
{
16+
printf("Not Palindrome");
17+
}
18+
return 0;
19+
}
20+
int p_d(int num)
21+
{
22+
if(num == reverse(num))
23+
{
24+
return 1;
25+
}
26+
return 0;
27+
}
28+
int reverse(int num)
29+
{
30+
int rem;
31+
static int sum=0;
32+
if(num!=0){
33+
rem=num%10;
34+
sum=sum*10+rem;
35+
reverse(num/10);
36+
}
37+
else
38+
return sum;
39+
return sum;
40+
}

0 commit comments

Comments
 (0)