-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpalindrome_5.c
45 lines (42 loc) · 1003 Bytes
/
palindrome_5.c
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
39
40
41
42
43
44
45
/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/
/*WAP to check whether a given 5 digit number is palindrome or not */
#include<stdio.h>
int main()
{
int num,rem,i,rev=0,num1,count=0;
printf("Enter the five digit number:\n");
scanf("%d",&num);
num1=num;
while(num>0)
{
rem=num%10;
rev=rem+rev*10;
num=num/10;
count++;
}
if(count==5)
{
if(num1==rev)
{
printf("The Given Number %d is Palindrome",num1);
}
else
{
printf("The Given Number %d is NOT Palindrome",num1);
}
}
else
{
printf("The given %d number is not a five digit number!",num1);
}
return 0;
}