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

/* First use of sumTo appears before its declaration.              */
/* Unsafe and only "works" because the compiler makes assumptions  */
/* about the function based on what it sees when it is first used. */

#include <stdio.h>

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;
}