Exforsys

Online Training

palindrome

This is a discussion on palindrome within the C and C++ forums, part of the Programming Talk category; how to check if any given number is a palindrome or not... the number is entered from the user...


Go Back   Exforsys > Programming Talk > C and C++

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 05:44 AM
Junior Member
 
Join Date: Feb 2008
Posts: 5
ankit_golden is on a distinguished road
Question palindrome

how to check if any given number is a palindrome or not...
the number is entered from the user
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 11:07 AM
Junior Member
 
Join Date: Mar 2007
Location: coimbatore, india
Posts: 25
lawrence is on a distinguished road
palindrome

a = xxxxxxxxx;
b = a;
c = 0;

while(b > 0)
{
c *= 10;
c += b%10;
b = b/10;
}

if(a == c)
{
'palindrome';
}
else
{
'not palindrome';
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-19-2008, 10:36 AM
Junior Member
 
Join Date: Mar 2008
Posts: 1
monuasthana is on a distinguished road
palindrome

Quote:
Originally Posted by ankit_golden View Post
how to check if any given number is a palindrome or not...
the number is entered from the user
void main()
{
int n,d,sum=0,ori;
printf("\nEnter any No. :");
scanf("%d",&n);
ori=n;
while(n>=1)
{
d=n%10;
n=n/10;
sum=sum*10+d;
}
if(sum==ori)
printf("\n given number is a palindrome.");
else
printf("\ngiven number is a not palindrome.");
getch();
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Projects In Java Ro_Maniak Project Requests 5 07-15-2006 12:47 AM


All times are GMT -4. The time now is 05:42 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.