Hi everyone,
I'm trying to program a clock. Everything seems to work fine. I know my code could probably be more efficient (feel free to give me some cues ont that). There is one that is a bit off tough. When the °seconds° integer is only one digit, the number is written in the wrong column. When my "seconds" integer has two digits, there is no problem. But, when my "seconds" integer has a value between 0 and 9. the value is still written in the fourteenth column. The best would have my clock having a display of my seconds like this: 01-02-03-04-05-06-07-08-09-10 -11 and so on. What i have looks like after the "seconds" integer go back to 0. 09-19-29-39-49-59-69-79-89-99-10.What would be the simplest way to solve this. Is there a way to have my one digit integer to be written with a 0 before them?
Ie, there is no magic clever way to get “print” to automatically add the leading zeros for you - you’ll have to write extra code to print it, after figuring out that it’s necessary.
Does it mean i'm going to print the value of the integer N divided by ten two times?
Sort of
N / 10 will give you the integer result of the division by 10, ie the first digit When N is less that 10 the result will be zero
N % 10 will give you the remainder (modulo) of N divided by 10, ie the second digit