title: Why isn't the unsigned long long int showing the right value in C?
body: <p>I am writing a program that converts decimal to unbalanced ternary but when I take a decimal input of of 1000000000, it will show a undesired value. I have used <code>unsigned long long int</code> as the data type of sum which is the data that I am printing. I have calculated the ternary number of 1000000000 is 19 digits long which shouldn't be aproblem as the range of ull is 20 digits long.
  I am using codeblocks in windows 10.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;math.h&gt;
  
  int main()
  {
      int N,cycle = 1,ara[100];
      while(cycle &lt;= 100)
      {
          scanf("%d",&amp;N);
          if(N &gt;= 0)
          {
              int i = 0;
              while(N != 0)
              {
                  ara[i] = N % 3;
                  N = N / 3;
                  i++;
              }
              unsigned long long int sum = 0;
              int j;
              for(j = 0;j &lt; i;j++)
              {
                  sum = sum + (ara[j]*(int)(pow(10,j)+0.5));
              }
              printf("%llu\n",sum);
          }
          else
          {
              break;
          }
          cycle++;
      }
      return 0;
  }
  </code></pre>