typedef int bool;
bool is_open = 1;

typedef int feet;
feet length, width;
length = 3;
width = 3 + 2



typedef int feet;
typedef int kilometers;
feet height = 1000;
kilometers size = 5;
height = size;

for each grade in ("A", "A-", ...)
  if my weighted total score
     >= minimum weighted total for grade
  then return grade

return "F"

/* number of different grades:
   Perfect, A, A-, B+, ..., D- */
#define NUM_GRADES 12

char* find_grade(double my_wtotal, ...)
{
  static char *grade_strings[] = {
  "Perfect", "A", "A-", "B+", "B", "B-",
  "C+", "C", "C-", "D+", "D", "D-"};

  int i;

  for (i = 0; i < NUM_GRADES; i++) {
    if (wtotal >= weighted_total(...) {
      return(grade_strings[i]);
    }
  }
  return("F");
}

#define PERFECT 0

char* find_grade(double my_wtotal,
  double quizzes[], double labs[],
  double hws[], double exams[])
{
  /* ... */
    if (wtotal >= weighted_total(
     quizzes[i], quizzes[PERFECT],
     labs[i]+hws[i],
     labs[PERFECT]+hws[PERFECT],
     exams[i], exams[PERFECT])) {
     /* ... */
     }
}


char* find_grade(double my_wtotal,
  double *quizzes, double *labs,
  double *hws, double *exams)

/* minimum grade arrays are such that the
   0th element corresponds to a perfect
   score, the 1st element to the minimum
   score for an 'A', the 2nd element
   to the minumum score for 'A-', etc. */
typedef double mins_array[NUM_GRADES];

#define KINDS	4

enum kinds {QUIZ, LAB, HW, EXAM};

mins_array mins[KINDS];

char* find_grade(double wtotal,
                 mins_array mins[KINDS])
{
  static char *grade_strings[] = {
   "Perfect", "A", "A-", "B+", "B", "B-",
   "C+", "C", "C-", "D+", "D", "D-"};

  int i;

  for (i = 0; i < NUM_GRADES; i++) {
    if (wtotal >= weighted_total(
     mins[QUIZ][i], mins[QUIZ][PERFECT],
     mins[LAB][i] + mins[HW][i],
     mins[LAB][PERFECT]+mins[HW][PERFECT],
     mins[EXAM][i], mins[EXAM][PERFECT])) {
      return(grade_strings[i]);
    }
  }
  return("F");
}

#include <stdio.h>
#include "print_errors.h"

int main(int argc, char *argv[])
{
  FILE *fp;
  void shpp(FILE *fp);

  program_usage_init(argv[0], "[file]");

  if (--argc == 0) {
    shpp(stdin);
  } else if (argc == 1) {
    /* allow single - to stand for stdin */
    if (strcmp(argv[1], "-") == 0) {
      shpp(stdin);
      exit(0);
    }
    /* argument should be a file name */
    if (argv[1][0] == '-') {
      usage();
    }
    if ((fp = fopen(argv[1],"r")) == NULL){
      sys_err("cannot read %s", argv[1]);
    }
    shpp(fp);
  } else {
    usage();
  }

  return(0);
}

int main(int argc, char *argv[])
{
  extern int getopt(int argc, char **argv,
	            char *optstring);
  extern int optind;
  /* ... */
  char mins_file_name[256];
  FILE *minsf;    
  bool give_percentage = false;
  bool debug = false;
  int i, c;

  program_usage_init(argv[0],
           "[-pd] [minimum-grade-file]");

  while ((c=getopt(argc,argv,"pd")) != -1){
    switch (c) {
    case 'p':
      give_percentage = true;
      break;
    case 'd':
      debug = true;
      break;
    default:
      usage();
      break;
    }
  }
      
  if (argc - optind >= 2) {
    usage();
  }

  if (argc - optind == 1) {
    strcpy(mins_file_name, argv[optind]);
  } else {
    strcpy(mins_file_name,
	   DEFAULT_MINS_FILE);
  }

  if ((minsf = fopen(mins_file_name,"r"))
      == NULL) {
    sys_err("cannot read %s",
            mins_file_name);
  }
  /* ... */
}

int iterate(int (*f)(int), int num, int x)
    /* effect: returns f(...(f(x))...)
	where f is applied num times */
{
  (num == 0) ? x ? f(iterate(f, num, x));
}


/* example call: */
res = iterate(T, 3, 4);

void *generic[2];
int i = 27;
double d = 3.14159;
generic[0] = (void *) &i;
generic[1] = (void *) &d; 
printf("%d %g\n", *((int *) generic[0]),
	*((double *) generic[1]));

