[ create a new paste ] login | about

Link: http://codepad.org/kvSiE91H    [ raw code | output | fork ]

C, pasted on Sep 12:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int main()
{
int n = 10, i;
float a = 2, b = 9, sum = 0, div;
for(i = 0; i < n; i++)
{
 div = a/b;
 sum += div;
 a += 3;
 b += 4;
}
printf("The sum is %f", sum);
return 0;
}


Output:
1
The sum is 5.253715


Create a new paste based on this one


Comments: