Write a C program to check whether a number is palindrome or not


Introduction

Write a C program to check whether a number is palindrome or not.


What is Palindrome number?

Palindrome number is such number which when reversed is equal to the original number.
For example: 2, 212, 12321, 2002 etc


techstudy.org

Kindle Paperwhite High Resolution Display Tablet | Rs. 9999

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h>
int main()
{
    int num, i, rev;

    // Reading a number from user
    printf("Enter any number: ");
    scanf("%d", &num);

    rev = num;
    for(i=0; num>0; num=num/10)
    {
        i = i * 10;
        i = i + (num%10);
    }

    //Checking if reverse number is equal to original num or not.
    if(rev == i)
       printf("%d is Palindrome Number.", rev);
    else
       printf("%d is not a Palindrome Number.", rev);
    return 0;
}

Result

C language

     





Related Topics


Responses




Popular Posts

Facebook

Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer and technology lovers. http://www.techstudy.org/.