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

后端 未结 13 1470
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:28

    You can try the following:

    // Multiple of 10
    if ((num % 10) == 0)
    {
       // Do something
    }
    else if (((num / 10) % 2) != 0)
    {
        // 11-20, 31-40, 51-60, 71-80, 91-100
    }
     else
    {
        // Other case
    }
    

提交回复
热议问题