#Magic date in cpp

6 messages · Page 1 of 1 (latest)

shy frost
#

I was trying to do this old challenge when i encoutered an issue. How do we take the last number of the year seperately. The year as a whole is one variable. I did it once with spaces between the digits of the year but then realised its ineffecient

#

Magic date in cpp

mellow minnow
#

Hmm, if you're using one variable of type int you can do modular division by 10 aka %10

#

Or just use string and index it to get digits, even using char array is possible since year is 4 digitis + 1 space for null char