Answer to Question #274780 in C++ for Asif

Question #274780

4. Write a C program to input number from user and check number is palindrome or not using while loop.

1
Expert's answer
2021-12-06T16:43:52-0500
#include <stdio.h>

int main()
{
   int d;
   printf("Enter a number: ");
   scanf("%d", &d);
   int r, i = d;
   while (i > 0) 
   {
       r = r * 10 + (i % 10);
       i /= 10;
   }
   if (r == d)
       printf("%d is a palindrom\n", d);
   else
       printf("%d is a not palindrom\n", d);
   return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment