UncleCoder.com

UncleCoder.com

Free programming examples and instructions

C program to check palindrome

C program to check palindrome

by Krishna viswambharan


Posted on 25 Sep 2017 Category: C Views: 401

Edited on 27 Sep 2017


An integer is a palindrome if the reverse of that number is equal to the original number. Here is a sample C code to check whether the number is palindrome or not.

#include <stdio.h>
#include <conio.h>
void main()
{

    int n,temp,reverse=0;
    printf("Enter the number :");
    scanf("%d",&n);
    temp=n;

/*reversing the given number*/
    while(temp!=0)
    {
        reverse=reverse*10;
        reverse=reverse+temp%10;
        temp=temp/10;
    }
    if(n==reverse)
        printf["The number %d is palindrome ",n);
    else
        printf("the number is not palindrome");
 }

output



Leave a Comment:


Advertisement