Write a C Program To Write function which returns 1 if the given number is palindrome otherwise returns 0
1: #include<stdio.h>
2: #include<conio.h>
3: int pelindrome(int);
4: int main()
5: {
6: int n,p;
7: clrscr();
8: printf("Enter a number : ");
9: scanf("%d",&n);
10: p=pelindrome(n);
11: if(p==1)
12: printf("%d is pelindrome",n);
13: else
14: printf("%d is not pelindrome",n);
15: getch();
16: return 0;
17: }
18: int pelindrome(int n)
19: {
20: char a[6],b[6];
21: itoa(n,a,10);
22: strcpy(b,a);
23: strrev(b);
24: if(strcmp(a,b)==0)
25: return 1;
26: else
27: return 0;
28: }
No comments:
Post a Comment