This week's book giveaway is in the Testing forum.We're giving away four copies of The Way of the Web Tester: A Beginner's Guide to Automating Tests and have Jonathan Rasmusson on-line!See this thread for details.
Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# Automorphic Number Problem

Ranajoy Saha
Ranch Hand
Posts: 99
2

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
Posts: 21745
85
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
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
Thanks for the help Henry Wong! Thank you very much! I corrected my mistake!