fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int num, temp, digits[10], count = 0;
  6. int isPalindrome = 1;
  7.  
  8. printf("Enter an integer: ");
  9. scanf("%d", &num);
  10.  
  11. temp = num;
  12. while (temp != 0) {
  13. digits[count] = temp % 10;
  14. temp = temp / 10;
  15. count++;
  16. }
  17.  
  18. for (int i = 0; i < count / 2; i++) {
  19. if (digits[i] != digits[count - i - 1]) {
  20. isPalindrome = 0;
  21. break;
  22. }
  23. }
  24.  
  25. if (isPalindrome)
  26. printf("%d is a palindrome number\n", num);
  27. else
  28. printf("%d is not a palindrome number\n", num);
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 5320KB
stdin
121
stdout
Enter an integer: 121 is a palindrome number