SHOW:
|
|
- or go back to the newest paste.
| 1 | - | #All this function does is count up and add up the numbers it goes through from 0 to n |
| 1 | + | int |
| 2 | - | |
| 2 | + | sum_c(int *x, size_t len) |
| 3 | - | void sum_c(int *x) |
| 3 | + | |
| 4 | int sum = 0; | |
| 5 | - | int tmp=0; |
| 5 | + | int *p; |
| 6 | - | for(int i = 0; i<x[0];++i) |
| 6 | + | for(p = x; p < x + len; ++p) |
| 7 | {
| |
| 8 | - | tmp += i; |
| 8 | + | sum += *p; |
| 9 | } | |
| 10 | - | x[0]=tmp; |
| 10 | + | return sum; |
| 11 | } |