Home Uncategorized Palindrome or Not in C

Palindrome or Not in C

SHARE


Here we written code to check whether the given number is palindrome or not.

For improvement of your coding skills we give some tasks along this. If you solve this tasks and send to our email
(onlineexamshubteam@gmail.com) with your details. we will display your details(like Name, City, college, photo) in our site.

Task: Write a C program to generate palindrome numbers from ‘m’ to ‘n’ natural numbers.
For example user entered 163 & 193 then output will be : 171 181 191

Write a C Program to Find whether the given number palindrome or not.

#include<stdio.h>
int main()
{
   int n,s=0,a,t; //’n’ for user defined integer,’s’ for store resultant ,’t’ for temporary, ‘a’ for calculations.
   printf(“Enter a value : “);
   scanf(“%d”,&n); // Read the number.
   t=n;
   while(t>0) //If entered number is greater than zero then only loop will execute
   {
      a=t%10; //pick last digit from temporary variable.
      s=(s*10)+a; //adding ‘a’ to ‘s’ as next digit to the existed number in ‘s’
      t=t/10; //removing last digit from ‘t’
   }
   if(n==s)
      printf(“Given number is palindrome\n”);
   else
      printf(“Given number is not palindrome\n”);
   return 0;
}

Output:
i) Enter a value : 4774
Given number is palindrome

ii) Enter a value : 25725
Given number is not palindrome

Back to the programs list.

Task Achievers

Till now no one is answered.