C Program to Check Palindrome Number

0
1693

In mathematics, a palindrome number is defined as a number which remains the number when its digits are reversed. As the palindrome numbers carry great significance in mathematics, physics and engineering, the study of palindrome number is considered essential in all science related faculties.

Checking palindrome number is a popular tutorial of C programming language to learn the basic looping techniques. It also gives the idea of the most widely used input and output functions such as printf() and scanf() along with implementation of simple mathematical operations of C language.

The basic working principle of the C program presented here is  reversion of  the given number.  In order to check if a number is palindrome or not, the number is initially reversed and then compared with the original number. If the number and its reverse are found to be same, the number is palindrome, else not.

Algorithm:

  • Start
  • Declare and initialize the necessary variables
  • Enter the number to be checked for palindrome property
  • Assign the number with temporary variable
  • Reverse the number the number using loop
  • Store the reversed number
  • Compare the reversed number and original number stored in temporary variable
  • If the number and its reverse are found to be same, print the number as palindrome number
  • Otherwise, the number is not palindrome
  • Stop

Source Code to Check Palindrome Number in C:

The above source code for checking palindrome number in C is short, simple and easy to understand. It includes a single and compulsory header file: stdio.h for using basic input and output library functions.

As this C program is executed, it asks for the number which is to be checked if it is palindrome. The number is stored in a temporary variable and then it is reversed. After that, the program compares the reverse and the original number; if they are found to be same, the number is palindrome. A sample output is shown below:

Check Palindrome Number in C Program Output

This source code in C program to Check Palindrome Number is to be compiled in Code::Blocks IDE. This tutorial is an important part and implementation of looping technique in C programming. If you have any queries regarding the any content of the post – the algorithm or source code, bring them up from the comments section.

LEAVE A REPLY

Please enter your comment!
Please enter your name here