A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

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

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

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

#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:

Enter any number: 121

121 is Palindrome Number.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now