-
Notifications
You must be signed in to change notification settings - Fork 323
/
Palindrome.c
29 lines (25 loc) · 644 Bytes
/
Palindrome.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
#include<stdio.h>
#include<string.h>
long long int max=1e6 +5;
int main()
{
//Defining a string to take input of the number
char number[max];
long long int len,i,count=0;
//Taking the inputin form of a string
printf("Enter a Number: ");
scanf("%s",number);
//Finding the number of digits by calculating the lenght of the string
len=strlen(number);
//Checking if the number is a palindrome or not
for(i=0;i<len/2;i++)
{
if(number[i]==number[len-i-1])
count++;
}
if(count==len/2)
printf("The entered number %s is a palindrome\n",number);
else
printf("The entered number %s is not a palindrome\n",number);
return 0;
}