title: Problems in compiling code due to the modulus operator
body: <p>I have written a program to store a number (which is predefined by the programmer) in form of digits in an array.</p>
  
  <p>For example, if I want to store a number 1234 in array arrx[4], then its elements would be:</p>
  
  <pre><code>arr[0] = 1
  arr[1] = 2
  arr[2] = 3
  arr[3] = 4
  </code></pre>
  
  <p>I try to achieve this using the below piece of code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;math.h&gt;
  
  using namespace std;
  
  int main()
  {
      int arrx[4];    // Stores the individual digits of number as array
      int digx = 4;   // Total number of digits in number
      int i;
      long int dupx = 1234;  // Number which has to be stored in array
      for(i = digx-1; i &gt;= 0 ; i--)
      {
          arrx[digx-i-1] = int(dupx/pow(10,i));
          dupx = dupx%(pow(10, i));
      }
      return 0;
  }
  </code></pre>
  
  <p>However, when I try to compile the above code, I get the following error message:</p>
  
  <blockquote>
    <p>error: invalid operands of types 'long int' and 'double' to binary 'operator%'</p>
  </blockquote>
  
  <p>The only conclusion which I was able to draw from above error was that the problem is with the modulus operator.</p>
  
  <p>Therefore, I have following questions in my mind</p>
  
  <ol>
  <li><p>What exactly is the problem with the code containing modulus operator?</p></li>
  <li><p>How can I fix this?</p></li>
  </ol>
  
  <p>I am using Code::Blocks version 17.12 with GNU GCC as my compiler.</p>