title: Second digit from the right from a huge number
body: <p>Now I actually read about modular arithmetic and managed to get the last digit of some number. Okay. But now... How do I get second last digit? Second one on the right. I actually been working on it on several hours straight trying to find a simple solution, this is the best I could come up so far but it's still not it. Could somebody help me please?</p>
  
  <p>This is what I have so far</p>
  
  <pre><code>long long powmod(long long n, long long exp)
  {
      long long r, result = 1;
  
      while(exp)
      {
          r = exp % 2;
          exp /= 2;
          if(r == 1) result = result * n % 10;
          n = (n * n) % 10;
      }
      return result;
  }
  </code></pre>
  
  <p>Thanks in advance</p>