C Programming : program will give the reverse of given natural number and it also check the palindrome of given number.

Posted on:
tags: , ,

/* This is a 'C' program.
This program will give the reverse of given natural number as output
and it also check the palindrome of given number.*/
#include<stdio.h>
#include<conio.h> //header files
void main()
{
int a,n,t,sum;//variables
clrscr();
printf("\n Enter a number [natural number]:");
scanf("%d",&n);
t=n;
sum=0;
while(n>0)
{
a=n%10;
sum=sum*10+a;
n=n/10;
}
printf("\n The Reverse of given number is:%d",sum);
if(t==sum)
printf("\n And the given number is Palindrome!!!");
else
printf("\n And the given number is Not Palindrome!!!");
getch();
}

No comments:

Post a Comment

< >