C function code help.
Go to solution
Solved by spenser_l,
You would be using function 1 to extract the most significant digit, and the second function to find the remainder, and repeat.
Since your range is 1 - 32767 (215) it makes sense that the example output shows 0 4 5 6 2
So input is 4562
4562 / 10000 = 0 (integer division)
4562 % 10000 = 4562
4562 / 1000 = 4
4562 % 1000 = 562
562 / 100 = 5
562 % 100 = 62
62 / 10 = 6
62 % 10 = 2
2 / 1 = 2
printing the output we get using the first function (which gives us the most significant digit): 0 4 5 6 2
I'll leave it to you as to how to properly store and loop through using the 2 functions you already made.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now