Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    C Program to Check Whether the Given Number Is a Palindrome

    C Programming Examples


    This C program checks the number given by the user whether it is a palindrome or not. It reverses the number using a while loop and matches the reversed number with the user input using the decision statement.

    What Is Palindrome Number

    A palindrome number is a sequence of numbers that can be read alike from the front and back in the same sequence.

    Example C Program:
    #include <stdio.h>
    
    void main() {
      /* Variable Declaration and Initialization. */
      int input, reverse = 0, rem, temp;
    
      /* taking user input */
      printf("Please enter an integer number:");
      scanf("%d", & input);
      temp = input;
    
      /* Reverse the number using while loop */
      while (temp != 0) {
        rem = temp % 10;
        reverse = reverse * 10 + rem;
        temp /= 10;
      }
    
      /* Check the reversed number with the user input */
      if (reverse == input)
        printf("%d is a palindrome number.", input);
      else
        printf("%d is not a palindrome number.", input);
    }

    Program Output:

    Please enter an integer number:: 1331
    1331 is a palindrome number
    


    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.