Check Whether Given Number Is Palindrome or Not

Check Whether Given Number Is Palindrome or Not

#include<stdio.h>
#include<string.h>

int main()
{
   int num, i, count = 0;
   char str1[10], str2[10];

   printf("Enter a number:\n");
   scanf("%d", &num);

   //Convert Number to String
   sprintf(str1, "%d", num);

   //Copy String into Other
   strcpy(str2, str1);

   //Reverse 2nd Number
   strrev(str2);   //in some compiler strrev function is not defined so error may be generated

   count = strcmp(str1, str2);

   if (count == 0)
      printf("%d is a prime number\n", num);
   else
      printf("%d is not a prime number\n", num);

  
Copyright © C Program | Java | OpenGL Programming | Hadoop at Computaholics