在C中划分后找到剩余物

你需要使用除法和余数10,

考虑这个例子,

163 divided by 10 is 16 and remainder is 3 16 divided by 10 is 1 and remainder is 6 1 divided by 10 is 0 and remainder is 1 

请注意,余数始终是要分割的数字的最后一位数。

我怎么能在C这样做?

它看起来像家庭作业所以我不会给你代码,但我建议你研究模运算符以及如何使用它来解决你的任务。

使用Modulus运算符:

  remainder = 163 % 10; // remainder is 3 

它适用于任何数字:

  remainder = 17 % 8; // remainder is 1, since 8*2=16 

(这适用于C和C#)

使用模数运算符( % ):

 15 % 12 == 3 17 % 8 == 1