mhdew

Palindrome

Nov 8th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. int a, rem, i=0, count=0, n, j;
  6. int ara[10000], p;
  7.  
  8. scanf("%d", &a);
  9.  
  10. for(;;){
  11. rem=a%10;
  12. a=a/10;
  13.  
  14. if(rem==0)
  15. break;
  16. count++;
  17. ara[i]=rem;
  18. i++;
  19. }
  20. n=count-1;
  21.  
  22. for(i=0,j=n;i<=j;i++,j--){
  23. if(ara[i]==ara[j])
  24. p=1;
  25. else
  26. p=0;
  27. if(p==0)
  28. break;
  29. }
  30.  
  31. if(p==1)
  32. printf("Palindrome\n");
  33. else
  34. printf("Not Palindrome\n");
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment