Hello Hello ! Help me with this please, is a noob thing:
I am working on a function which return 1(true) if a int number is in ascending order.
For exemple:
--> 67 return 1;
--> 76 return 0;
--> 6 return 1;
--> 66 it is return what I want...i put it now to to return 1;
My question to you guys is, which one is Previous Number and Current number?
I solved the function , but I wanted to understand the code better.
SO i type 67 ,which one is Current,Previous Number.
I thought 6 is previous and 7 is curent...but is not working that well in code.
the code was given to me from a book !
Is really that hard ?
In programming, which one si considered previous number and current number.?
for exemple 56, which one is previous , and which one is current number/ figure.
oh, it's an English question? :) "previous" is just a relative term. If you're discussing natural numbers, that is: 1,2,3,4,5 ... , then if discussing 4, 3 is the previous number in the series.
Your context is likely digits. If my number was 987654, I could split it up into array indices to help solve the problem, so it's clear: [9, 8, 7, 6, 5, 4]. There is clearly an order here. Looking at "6", the previous number is 7 and the next number is 5.
I wrote a little function to solve it as well by examining digits from right to left with the help of our friendly modulus and integer division operators. I did end up making a variable called cur or the current digit that I compare to the "last" one (digit to the right, in my case). Since I annihilate the number with each iteration of the loop, I felt last was more appropriate than something like 'next' or 'previous'. Hope that helps in your understanding of these relative words. Really, they're more like implementation details to help progress the logic.