/* CSE 333 Su12 Lecture 3 demo: sum_declared.c */
/* Gribble/Perkins */

/* Illustrate use of function declarations to allow function calls to */
/* appear before the actual function definition. */

#include <stdio.h>

// this function prototype is a declaration of sumTo
int sumTo(int);

int main(int argc, char **argv) {
  printf("sumTo(5) is: %d\n", sumTo(5));
  return 0;
}

// return sum of integers from 1 to max
int sumTo(int max) {
  int i, sum = 0;
  
  for (i=1; i<=max; i++) {
    sum += i;
  }
  return sum;
}