;

C Program To Check Whether the Number is Palindrome or not


Tutorialsrack 03/11/2019 C

In this C program, we will learn how to write a program to check whether the number is Palindrome or not.

Here is the code of the program to check whether the number is Palindrome or not.

Code - C Program To Check Whether the Number is Palindrome or not
/* C Program To Check Whether the Number is Palindrome or not */

#include <stdio.h>

int main() {
    int Number, OriginalNumber, ReversedNumber = 0, Remainder = 0;
    printf("Enter the Number: ");
    scanf("%d", & Number);
    OriginalNumber = Number;
    while (Number > 0) {
        Remainder = Number % 10;
        ReversedNumber = ReversedNumber * 10 + Remainder;
        Number /= 10;
    }
    if (ReversedNumber == OriginalNumber) {
        printf("Entered Number is palindrome!");
    } else {
        printf("Entered Number is not palindrome!");
    }
    return 0;
}
Output

Enter the Number: 656
Entered Number is palindrome!
--------------------------------
Process exited after 2.028 seconds with return value 0
Press any key to continue . . .


Related Posts



Comments

Recent Posts
Tags