#number digit

13 messages · Page 1 of 1 (latest)

uncut tangle
#

pls use c++ and don’t use string or vector

I want to input a number and get its first digit and second digit.
Then subtract these two digits to form a new number and then determine the first digit and second digit of the new number. What should I do?
use while loop until the number<o?

bleak trellisBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

dense marsh
#

that could work yes

uncut tangle
#

how?

bleak trellisBOT
#
HolyBlackCat
We Don't Do Your Homework

Welcome to Together C & C++ :wave:

We won't do your homework for you (#rules) but we are happy to help you learn and point you in the right direction.

Please send what you have so far and ask a specific question.

dull sedge
#

Can you show your attempt as code, and tell us what problems you have with it?

edgy ravine
pale finch
# uncut tangle pls use c++ and don’t use string or vector I want to input a number and get its...

But... Wouldn't that just always result in you getting a 1-digit number after the very first iteration?
Because if you have e.g. 123456789 and you decide to grab first (1) and last digit (9) and you subtract them, then you get |1 - 9| = |-8| = 8 (assuming you want the absolute value).

What do you do then? Just do |8 - 8| in the next iteration because 8 was the first and last digit of the number 8?

Also why would you want to loop? Like, this is guaranteed to be 2 iterations at max.

#

If you're really (un-)lucky you could end up with only 1 iteration even, e.g. if your number is 4xxxxxxxxxxxx4, then you'd do |4 - 4| = 0 in the first iteration, meaning you're already finished.

Or ofc if your input number is 0 to begin with, then you're immediately finished

#

But I can't see any other scenario than 0, 1 or 2 iterations

dense marsh
#

i guessed it was subtracting 8 from 123456789

#

idk