 <p>First off you are looping through your calculateAverage funtion 4 times. Are you doing this on purpose? I think you should only do this once. </p> <p>Second, in your while loop</p> <pre><code>while (grade &lt;= 100 &amp;&amp; grade != -1) { numberofGrades++; sumofGrades += grade; average = sumofGrades / numberofGrades; } </code></pre> <p>you are infinitely looping. This will loop forever if a value other than -1 is entered. This should be changed to an if statement.</p> <pre><code>if (grade &lt;= 100 &amp;&amp; grade != -1) </code></pre> <p>But there is a better way to write this code (if I am guessing what you actually want it to do)</p> <pre><code>#include &lt;stdio.h&gt; float calculateAverage (int sum, int size); int main(void) { int input; int sum = 0; int count = 0; while (input != -1 &amp;&amp; input &gt;= 0 &amp;&amp; input &lt;= 100) { printf ("Enter a Grade: "); scanf ("%d", &amp;input); if (input != -1) { sum += input; count++; } } float average = calculateAverage(sum, count); return 0; } float calculateAverage (int sum, int count) { // Do your average math here.... } </code></pre>