GoogelAddUnit1

Monday, 16 April 2012

WRITE A C-PROGRAM TO TEST THE GIVEN NUMBER IS PALLINDROM (OR) NOT.

AIM:A program to test the given number is pallindrom (or) not.


PROGRAM:
#include<stdio.h>
main()
{
int n,rn=0,d,k;
printf("enter the value of n");
scanf("%d",&n);
k=rn;
while(n>0)
{
d=n%10;
rn=(rn*10)+d;
n=n/10;
}
if(k==rn)
printf("it is a pallindrom");
else
printf("it is not a pallindrom");
}

OUTPUT:
enter the value of n
121
it is a pallindrom
enter the value of n
456
it is not a pallindrom

No comments:

Post a Comment