Can anyone figure out what is wrong in my program?

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Nov 2004
Posts: 12
Reputation: Extreme is an unknown quantity at this point 
Solved Threads: 0
Extreme Extreme is offline Offline
Newbie Poster

Can anyone figure out what is wrong in my program?

 
0
  #1
Nov 16th, 2004
I need to make a program to check if the entered number is palindrome or not i.e. if u take a number and reverse it it will be the same old number for example if u take 121..then if u reverse the number it will be 121 and so 121 is a palindrome number.

i wrote a program to check if a number is palindrome or not but it is not working properly :cry: ...Can any1 plz tell me wat is wrong..

The program which I wrote is below:-

  1.  
  2. #include<iostream.h>
  3. #include<conio.h>
  4.  
  5. void main()
  6.  
  7. {
  8.  
  9. int n, x, m=0;
  10.  
  11. cout<<"Enter any number"<<endl;
  12. cin>>n;
  13.  
  14. while(n>0)
  15.  
  16. {
  17.  
  18. m*=10;
  19.  
  20. x=n%10;
  21.  
  22. m+=x;
  23.  
  24. n/=10;
  25.  
  26. }
  27.  
  28. if(m==n)
  29.  
  30. cout<<"The entered number is a palindrome number"<<endl;
  31.  
  32. else
  33.  
  34. cout<<"The entered is not a palindrome number"<<endl;
  35.  
  36. getch();
  37.  
  38. }
Last edited by alc6379; Nov 16th, 2004 at 3:20 pm. Reason: added [code] tags
>>>Extreme<<<
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,867
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: Can any1 figure out wat is wrong in my program!!PLZ!!

 
0
  #2
Nov 16th, 2004
>if(m==n)
n is zero at this point, remember? Use a copy of n for your loop counter so that the original value is preserved.
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 12
Reputation: Extreme is an unknown quantity at this point 
Solved Threads: 0
Extreme Extreme is offline Offline
Newbie Poster

Re: Can any1 figure out wat is wrong in my program!!PLZ!!

 
0
  #3
Nov 16th, 2004
Hey thanx a lot Narue...my program is working Perfectly now!! :cheesy:

And once again Thanx a lot....
>>>Extreme<<<
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Can any1 figure out wat is wrong in my program!!PLZ!!

 
0
  #4
Nov 16th, 2004
Just a helpful hint here on the forum for you:

Cn u plz not use chat spk here? Wat do u want 2 do that for? U got all d time in d world 2 make a post, so there's no need 2 uz chat spk n here.

Please, for all of our eyes' sakes, spend about 30 seconds more on your post, and spell words in a non-lame fashion.

kthxbye!
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Can anyone figure out what is wrong in my program?

 
0
  #5
Nov 16th, 2004
tx alx, i culdnt ha sd it b8ter mself
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2
Reputation: muraliaa is an unknown quantity at this point 
Solved Threads: 0
muraliaa muraliaa is offline Offline
Newbie Poster

Re: Can anyone figure out what is wrong in my program?

 
0
  #6
Sep 16th, 2008
Your program is write up to if(m==n)

in the above program n will become zero
after the loop. So assign n value to any other variable,then compare with m.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,867
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: Can anyone figure out what is wrong in my program?

 
1
  #7
Sep 16th, 2008
Congratulations, muraliaa! It took you only four years to come up with the same answer as me.
Last edited by Narue; Sep 16th, 2008 at 9:46 am.
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,989
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 308
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: Can anyone figure out what is wrong in my program?

 
1
  #8
Sep 16th, 2008
This thread is so old, it saw the creation of the previous LHC
Attached Thumbnails
largehadroncollidertp3.jpg  
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,663
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1502
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Can anyone figure out what is wrong in my program?

 
0
  #9
Sep 16th, 2008
Originally Posted by Narue View Post
Congratulations, muraliaa! It took you only four years to come up with the same answer as me.
Some people are just a little slow
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 2856 | Replies: 8
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC