/* This program is from lab 5, meant to demonstrate how to read in from a file and how to write output to a file. It reads in the Mercedes used car prices data set, and writes out the mean price by model. */ /* gcc -o carsexample.exe carsexample.c */ #include #define NCASES 54 #define NMODELS 5 main(){ int i, j; /* indices, counters */ int casenum, age, mile, vend; /* variables we don't care about */ int price[NCASES]; /* prices of the cars */ int model[NCASES]; /* model numbers of the cars */ double priceave[NMODELS]; /* average price by model */ int modelcount[NMODELS]; /* number of cases by model */ FILE *fp; /* file pointer for input/output */ fp = fopen("mercedes.dat","r"); /* open file for reading */ for(i=0; i