# Help with program

• 12-04-2012
lol34543
Help with program
Hey guys,
I'm new to programming and I'm not sure why this program won't work. As soon as I enter the value of a on the console the rest of the program just won't run. I'm sure I'm just being stupid. Any help would be appreciated. Thanks.

Code:

```#include <stdio.h> #include <stdlib.h> #include <math.h>     float integral(int n, int a); int main(int argc, char* argv[]) {     int n, a;         printf("Enter your integer value of a: ");     scanf("%i", &a);             for (n = 1; n <= 10; n++)     {            printf("%i        %g\n", n, integral(n, a));     }     return 0; }    float integral(int n, int a) {        int N = 10000;     float x, y, strip, sum;                 for(x = 0; x < 1; x=x+(1/N))     {         y = (pow(x,n))/(x+a);         strip = y/(N);         sum += strip;     }         return(sum); }```
• 12-04-2012
Salem
Code:

```float integral(int n, int a) {      int N = 10000;     float x, y, strip, sum;                   for(x = 0; x < 1; x=x+(1/N))     {         y = (pow(x,n))/(x+a);         strip = y/(N);         sum += strip;     }         return(sum); }```
A couple of points.
1. Initialise sum to 0
2. Make N a float, otherwise 1/N is done in integer arithmetic, and the result is 0 (your loop never exits).
• 12-04-2012
lol34543
Thank you so much, I knew it would be something stupid haha.