How does the modulus operator work?

前端 未结 5 1625
忘了有多久
忘了有多久 2020-11-27 17:19

Let\'s say that I need to format the output of an array to display a fixed number of elements per line. How do I go about doing that using modulus operation?

Using C

5条回答
  •  粉色の甜心
    2020-11-27 18:02

    It gives you the remainder of a division.

    int c=11, d=5;
    cout << (c/d) * d + c % d; // gives you the value of c
    

提交回复
热议问题