Now you can use those facts to get each digit of a number. For example :
define n equal to 104
n mod 10 equals 4 and save 4
let n = n / 10 //n now equals 10 , 4 was removed
n mod 10 equals 0 and save 0
let n = n / 10 //n now equals 1, 0 was removed
n mod 10 equals 1 and save 1
let n = n / 10 // n now equals 0
since n is 0 STOP;
//now the digits we saved, do stuff with them
One more hint: you will need to know 4th grade math (add, subtract, multiply, and divide). What firstperson posted (except for the mod operator) was nothing more than what a 4th grader would learn in most USA schools.
We are here to help people with there code not give them the code if they don't have any. Secondly if you are going to post code please use code tags. Third your loop wont work like you think it does. When i is 1 it gets decremented to zero and then the for loop evaluates i and comes up false because i is 0 so you never get the last digit.
Also, I have never taken a programming class before so please excuse my lapse's of knowlage.
Yes mod returns the remainder from the division of its operands. For example,
10 mod 2 equals 0 because 2*5 equals 10, with 0 remainder. Another example,
5 mod 2 equals 1 because 2 goes into 5, 2 times with 1 remainder. Work it out on paper first and you will learn it better.
Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...