Commit 7a550e8c authored by Matthias Braun's avatar Matthias Braun
Browse files

am_test2

[r15581]
parent daadfb78
#include <stdio.h>
int arr[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int sum(int from, int to) {
int i, res = 0;
int len = to - from;
for(i = 0; i < len; ++i) {
res += arr[from + i];
}
return res;
}
int main(int argc, char **argv) {
int from = 0;
int to = 10;
if(argc > 1)
to = atoi(argv[1]);
printf("Sum: %d\n", sum(from, to));
return 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment