Defining a function outside main
<pre><code>#include &lt;stdio.h&gt;
#include &lt;math.h&gt;

main()
{
     float i;
     float x,N,sum;
     printf("enter x and N respectively");
     scanf ("%f %f", &amp;x, &amp;N);

     sum = 0;
     for (i=1;i&lt;=N;i++){
          sum = sum + ((pow(x,i))/(fact(i)));
     }
     printf ("%f", sum);
}

int fact(int n){
     int i,temp;
     temp = 1;
     for (i=1;i&lt;=n;i++){
          temp = temp*i;
          return temp;
     }

}
</code></pre>

<p>this is to print the summation of the terms accordingly. I tried defining fact inside main but there was some control flow warning and I tried the same outside this time, yet wrong answer. Any help?</p>