title: Solving C question possibly requiring while loop
body: <p>I have this C question:</p>
  <p>&quot;Write a program that reads a positive integer x and displays the maximum positive
  integer n for which the sum 1^2 + 2^2+ 3^2+ …+ n^2 is less than the given number.&quot;</p>
  <p>From what I understand, I have to print the value of n. I tried using a while loop to find the sum of numbers before x is reached, but my code isn't working properly. Any help? Thanks!</p>
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;math.h&gt;
  
  int main(){
  //while and for loop?
      int a = 90, n = 1;
      float sum;
      while(sum&lt;a){
          sum += pow(n,2);
          n++;
      }
      printf(&quot;%d&quot;, n);
      
  }
  </code></pre>