Computer Science, asked by YoungNino01, 7 months ago

write a C program that accepts a number as input from the user, and applies this algorithm to obtain the smallest/first palindrome number.

Answers

Answered by pavithranatarajan855
0

Answer:

#include <stdio.h>

int main() {

   int n, reversedN = 0, remainder, originalN;

   printf("Enter an integer: ");

   scanf("%d", &n);

   originalN = n;

   // reversed integer is stored in reversedN

   while (n != 0) {

       remainder = n % 10;

       reversedN = reversedN * 10 + remainder;

       n /= 10;

   }

   // palindrome if orignalN and reversedN are equal

   if (originalN == reversedN)

       printf("%d is a palindrome.", originalN);

   else

       printf("%d is not a palindrome.", originalN);

   return 0;

}

Explanation:

Similar questions