Determining if a number is either a multiple of ten or within a particular set of ranges

后端 未结 13 1463
Happy的楠姐
Happy的楠姐 2021-01-31 07:01

I have a few loops that I need in my program. I can write out the pseudo code, but I\'m not entirely sure how to write them logically.

I need -

if (num is          


        
13条回答
  •  时光说笑
    2021-01-31 07:27

    With a couple of good comments in the code, it can be written quite concisely and readably.

    // Check if it's a multiple of 10
    if (num % 10 == 0) { ... }
    
    // Check for whether tens digit is zero or even (1-10, 21-30, ...)
    if ((num / 10) % 2 == 0) { ... }
    else { ... }
    

提交回复
热议问题