5 Aug 2019

  • August 05, 2019
  • Amitraj



Palindrome number in C

A palindrome number is a which remains the same on reversal. For example, some palindrome numbers are 8, 121, 212, 12321, -454. To check whether a number is a palindrome or not first we reverse it and then compare the number obtained with the original number, if both are same then the number is palindrome otherwise not.

Check palindrome number algorithm
To test if a number is palindrome or not, do the following steps:

1. Get the number from a user.

2. Reverse it.

3. Compare it with the number entered by the user.

4. If both are the same then print palindrome number else print not a palindrome number.

/*   C Program to verify given no. is Palindrome or not */  


http://codevidyalay.blogspot.com

#include<stdio.h>
int main()
{
int n,r,m,sum=0;
printf("Enter a no:");
scanf("%d",&n);

m=n;
while(n>0)
{
r=n%10;
sum=sum*10+r;
n=n/10;
}

if(sum==m)
printf("Palindrome");
else

printf("Not palindrome");
return 0;
}


INPUT/OUTPUT:
Enter a no:123
Not palindrome

Related Posts:

  • Triangle pattern program in C /* C Program to print the following triangle pattern for given n*/       By Amit raj purohit     #include<stdio.h> int main() { int i,j,n; printf("Enter a no:"); scan… Read More
  • Biggest and Smallest no. in an Array /* C Program to find biggest and smallest no. in a given array*/ http://codevidyalay.blogspot.com  #include<stdio.h> void biggest(int a[],int n); void smallest(int a[],int n); int main() { int i,n,a[100]; print… Read More
  • Armstrong Number in C Armstrong Number in C Before going to write the c program to check whether the number is Armstrong or not, let's understand what is Armstrong number. Armstrong number is a number that is equal to the sum of cub… Read More
  • Perfect Number in C Perfect Number in C Here you will get program for perfect number in C. Perfect number is a positive number which is equal to the sum of all its divisors excluding itself. For example: 28 is a perfect number as… Read More
  • /* C Program to find the sum of individual digits of given no. */ /* C Program to find the sum of individual digits of given number*/ #include<stdio.h> int main() { int n,r,sum=0; printf("Enter a no:"); scanf("%d",&n); while(n>0) { r=n%10; sum=sum+r; n=n/10; } print… Read More

Translate

Popular Posts