/* program to use functions with value parameters to simulate a yoyo motion */

#include <stdio.h>

/* yoyo illustrates:
      function with 1 parameter:  count
                    2 local variables: i, reps
                    1 return value
*/
int
yoyo (int count) 
{
  int reps = 3*count;

  /* repeat motion */
  for (int i = 0; i < reps; i++) 
  { 
    printf("move forward 1\n");
    printf("move backward 1\n");
  } 
                  
  /* print local variables */
  printf ("in yoyo:  count = %d, reps = %d\n", count, reps);

  return reps; 
} // yoyo

/* main demonstrates a call to function with return value */
int
main (void)
{
  int repetitions, result;
  
  repetitions = 2;
  result = yoyo (repetitions);
  printf ("repetitions = %d,   result = %d\n", repetitions, result);

  return 0;
} // main
