gcc - throwing away tens & hundreds columns of an int in C -
I want to test an integer value for my unit column value, I do not care about tens or hundreds of columns. The int value is a countdown timer
So when the units column is 0 to 4, I want to display something in the screen, when the units are from 5 to 9, then I want to show the screen a bit more. I basically want to separate the units column value
without thinking of dividing by 100, one can not think of a quick and dirty way to do this and reduce the number of 100 to 10 with the number .
So far I am trying:
int zero_count_units = a_zero_count - (an easy way to transfer and test for 0 to 4 or 5 to 9 in the unit column Is ((A_zero_count / 100) * 100) + ((a_zero_count / 10) * 10)); If ((zero_count_yats> = 0) & amp; amp; amp; amp; amp; (0x;) // 5-9 unit column {} My brain is not working very well this morning! Thanks very much any advice!
You must use the % () operator for expression n and m n% m is separated by n . In your case m will be 10, because You divide into ten Since you are interested in remaining: const int Suny_gn_ank = a_zero_count% 10;
Comments
Post a Comment