title: How do I find the time complexity (Big O) of while loop?
body: <p>Code 1</p>
  
  <pre><code>int i = 0;
  int j = 0;
  while(i &lt; n){
       while(j &lt; n){
          printf("{%d,%d}",arr[i],arr[j]);
          j++;
      }
      i++;
      j = 0;
      printf("\n");
  }
  </code></pre>
  
  <p>Code 2</p>
  
  <pre><code>int result = 0;
  int i = 0;
  while (i &lt; n / 2){
      result += arr[i];
      i += 1;
      while (i &gt;= n / 2 &amp;&amp; i &lt; n){
          result += arr[i];
          i += 1;
      }
  }
  printf("%d\n", result);
  </code></pre>
  
  <p>I only know how to find time complexity with for loops, but I am uncertain about while loop.
  It would be greatly appreciated if someone could help me find the total running time of each code.</p>