Is Palindrome in C
Level 3135 keystrokes
Checks if a number is a palindrome by reversing its digits.
C code
// orig keeps a copy, because the loop destroys num1int num = 121, orig = num, rev = 0;// Build the reversed number one digit at a time2while (num > 0) { // Shift rev left by one digit and add the last digit of num: 1, 12, 1213 rev = rev * 10 + num % 10; // Remove that digit from num4 num /= 10;5}// The ternary ?: picks "Yes" because 121 reads the same reversed6printf("%s", orig == rev ? "Yes" : "No");Output
Yes
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C code and how often they appear.
=× 7"× 6;× 4,× 3(× 2)× 2%× 2:× 1?× 1{× 1