Develop a program to find the reverse of positive integer and check for palindrome or not Display appropriate messages

All QuestionsCategory: C LanguageDevelop a program to find the reverse of positive integer and check for palindrome or not Display appropriate messages
nikhil.d asked 3 years ago
2 Answers
nikhil.d answered 3 years ago

#include <stdio.h>
int main()
{
    int rev, digit, n, m;
    printf(“Enter four digit number”);
    scanf(“%d”, &n);
    m = n;

    while (n != 0)
    {
        digit = n % 10;
        n = n / 10;
        rev = rev * 10 + digit;
    }
    printf(“Reverse number is %d \n”, rev);
    if (m == rev)
        printf(“Number is a palindrome”);
    else
        printf(“Not a palindrome”);
}

Chetan Shidling Staff answered 3 years ago

Note: Change the double inverted comma ( \” ) in the code to avoid an error.