Wednesday 20 August 2014

Palindrome in c

Q:- Write a program in C to check whether the number is palindrome or not.

    A palindrome is a number whose reverse is the same as the number itself like 
121,1331,111 etc.
CODING
#include<conio.h>
#include<stdio.h>
void main()
{
int n,reverse,no,d;
char ch;
clrscr();
do
{
printf("\nEnter an integer\n");
scanf("%d",&n);
no=n;
reverse=0;
while(n>0)
{
d=n%10;
reverse=reverse*10+d*d*d;
n=n/10;
}
if(reverse= = no)
printf("%d is a palindrome number",no);
else
printf("%d is not a palindrome number",no);
printf(\npress y to continue\n");
ch = getche();
}
while ((ch= = 'y')||(ch = = 'Y'));
getch();
}
                                                                                                         BY:- DANISH SHABIR
                                                                                    EMAIL ID:-beigh.danish@gmail.com
                                                                                                  submit to reddit

No comments:

Post a Comment

Tell Us What You've Got...