/*1 */ // sum_C.c
/*2 */ // calculates a sum by calling a C function
/*3 */ 
/*4 */ #include <stdio.h>                // required for printing output
/*5 */ short sum_c_func(short k);        // prototype for C function
/*6 */ 
/*7 */ short N=3;                        // number of integers to sum
/*8 */ short sum;                        // store value returned from sumcfunc
/*9 */ 
/*10*/ short sum_c_func(short k)
/*11*/ {
/*12*/  short i;
/*13*/  short total = 0;
/*14*/ 
/*15*/  for (i=k; i>=0; i--)             // sum from top to bottom
/*16*/  {
/*17*/          total += i;
/*18*/  }
/*19*/ 
/*20*/  return(total);
/*21*/ }
/*22*/ 
/*23*/ void main()
/*24*/ {
/*25*/   sum = sum_c_func(N);            // call sum_c_func to calculate sum
/*26*/   printf("Sum = %d\n", sum);        // print result
/*27*/ }
 
