Skip to main content

Checking whether a number is Palindrome.

PROCEDURE:-
    1.input an integer value n
    2.set sum to 0
    3.repeat steps 4 to 6 until n is greater than 0
    4. find n modulo 10 and assign it to r
    5.set sum=sum*10+r
    6.new value of n is equal to n/10
    7.if n and sum values are equal then print n is palindrome
    8.else print n is not palindrome
CODE:-

#include<stdio.h>
void main()
{
int n,r,s=0,m;
printf(“enter value for n”);
scanf(“%d”,&n);
m=n;
while(n>0)
{
    r=n%10;
    s=s*10+r;
    n=n/10;
}
if(s= =m)
printf(“ %d is a palindrome”,m);
else
printf(“%d is not a palindrome”,m);
}
Input:- enter value for n  121
Output:- 121 is a palindrome

Comments