I have encountered many problems and in some I could find the algorithms but in some I fail to do so.
Last year we had to make programs regarding armstrong number or palindrome number.I could not make them and I had to "learn" them for exams and I really hate to do that.I asked my teacher but he didn't say anything.I could make those programs if I knew the number of digits in the value.
Please help me how can I improve my skills.
Here is the way I think :-
Example -
Check for palindrome (supposing the number contains three digits)
1.First I thought what I do to solve this problem in real life.
Ans - I just look up first and last number (since its a 3 digit no.)
2.Now, what can I do to make the computer understand this.
3.Simple, I need to forge a code which can determine the first and last digit.
4.How can I do that ?
5.Simple - for the hundreds place I will divide the number by 100 (taking integer value) suppose my number is 423(integer type).So dividing it by 100 will give 4 (since our storing variable is an int type).
Now similarly with some more code I could find the tens digit and compare the two.
I could also make the program for 4 digit number.
But I came up totally clueless if I didn't know the no of digits in the value.
How to overcome such type of problems in future?
Please help me.I need help big time.Except suggesting to mug up the code you can do anything.
Please please please help me.
Thanks