// An example of a C program with a function with // one input and a return value #include int sum_to(int n); int main(void) { int max = 10; int result = sum_to(max); printf("Sum 1.. "); printf("%d", max); printf(" = "); printf("%d", result); putchar('\n'); return 0; } // An iterative solution int sum_to(int n) { int sum = 0; int i = 1; sum_to_loop: if (i > n) goto sum_to_loop_end; //while (i <= n) { sum = sum + i; i = i + 1; goto sum_to_loop; sum_to_loop_end: return sum; }