• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Automorphic Number Problem

 
Ranajoy Saha
Ranch Hand
Posts: 99
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I have created this program which checks a number is Automorphic or not. Automorphic numbers are the numbers whose square ends with the number itself or you can say it is a number whose square ends with the given integer. Eg. Square of 5 is 25 As 25 has the last digit 5 so 5 is an automorphic number. This porgram is always giving me "The number is a automorphic number." no matter whatever number I try. I cant detect the problem in this program. Please help!
 
Henry Wong
author
Marshal
Pie
Posts: 21496
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranajoy Saha wrote:

I have created this program which checks a number is Automorphic or not. Automorphic numbers are the numbers whose square ends with the number itself or you can say it is a number whose square ends with the given integer. Eg. Square of 5 is 25 As 25 has the last digit 5 so 5 is an automorphic number. This porgram is always giving me "The number is a automorphic number." no matter whatever number I try. I cant detect the problem in this program. Please help!



If you follow the code, how often is the check variable set? And what is it set to? ... Interestingly, this value is the same regardless of what number the user enters.

Henry
 
Ranajoy Saha
Ranch Hand
Posts: 99
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, Henry Thanks for helping! Previously the check variable was initialized with 0 as num then was 0 and there was no change at all. But now I first initialized the check variable to 0 and then after the user has entered some input then it get's initialized by num.
But still the output is the same as before!
 
Ranajoy Saha
Ranch Hand
Posts: 99
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help Henry Wong! Thank you very much! I corrected my mistake!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic