Yesterday was full of chemistry in various incarnations. I had to study some Organic Chemistry (Mechanisms, bah!), had Chemical Engineering homework (real gases, fun stuff... Take that, Ideal Gas Law!). Also spent about an hour and a hlaf finishing up my program. I made such a stupid mistake, and couldn't figure out for the longest time why it wasn't working right. Grrr... It's really long, and insane.
#include [stdio.h]
#include [ctype.h]
/* Includes the libraries needed for the program */
#define INFILE "A:data.txt"
#define OUTFILE "A:result.txt"
/* Defines files used for the program */
int cnt; /* Tells how much data there is for each day */
float temp[25]; /* Original temperature array, all in ºF */
float order[25]; /* Temperature array in ascending order */
float avg; /* Average of all temperatures for that day */
/* Declares variables used in main and other functions */
int main(void)
/* Begins the main function */
{
int i, j; /* loop controls */
int day=1; /* day variable */
int min; /* Minimum temperature for that day */
int max; /* Maximum temperature for that day */
float initial_temp; /* Temperature before scale conversion */
char scale; /* Temperature scale, F or C */
/* Declares the variables used only in the main function */
float average(float x[], int n);
void sort(float x[], int n);
/* Declares the other functions used in the program */
FILE * infile;
FILE * outfile;
/* Declares the files */
infile = fopen(INFILE, "r");
outfile = fopen(OUTFILE, "w");
/* tells which file to read from and which to write to */
printf("Joshua Welshans\n");
printf("Day\t Low\t Average\t High\n");
printf("---\t ---\t -------\t ----\n");
fprintf(outfile, "Joshua Welshans\n");
fprintf(outfile, "Day\t Low\t Average\t High\n");
fprintf(outfile, "---\t ---\t -------\t ----\n");
/* writes heading to sceen/file */
while(fscanf(infile, "%i", &cnt)==1)
/* while loop that reads the first value from the file into the cnt variable */
{
switch(cnt)
/* Switch around cnt variable */
{
case 0: /* If cnt=0 (No data) */
printf("%i No data\n", day);
fprintf(outfile, "%i No data\n", day);
/* Prints the data to screen/file */
day++;
/* Incriments day variable */
break;
/* Gets out of the switch statement */
case 1: case 2: case 3: case 4:
/* If cnt=1, 2, 3, or 4 (Not enough data) */
printf("%i Not enough data\n", day);
fprintf(outfile, "%i Not enough data\n", day);
/* Prints data to screen/file */
for(i=0; i
Today I woke up early (after about 6 hours of sleep) to register for next semester. I didn't get the math class I wanted. ;_;
Spring 2005
ChE 202 - Material and Energy Balances 2
MW 3:00 - 4:50
ChE 230 - Numerical Methods for Chemical Engineers
TR 3:00 - 4:50
Math 251 - Multivariable Calculus
MWRF 1:30 - 2:20 (hopefully getting changed)
Phys 111 - General Physics 1
MTWF 9:30 - 10:20
Physics Lab
W 10:30 - 12:20
Phil 170 - Intro to Critical Thinking
TR 11:30 12:45