//Linda Mac Phee //Feb 96 //This program calculates area of saturation of a gas //assume: k(incoming gas) = 10 units/unit of time //assume: 50% incoming and 50% outgoing gas molecules //add library files w/ ness. functions #include //define constants #define K 10 //incoming gas #define ROW 20 #define COL 20 //main doesn't return a value int main(void) { //define local variables double n[ROW][COL]; //array to hold data int r, c; //loop control //initalize variables for( r = 0; r < ROW; r++) for( c = 0; c < COL; c++) n[r][c] = 0; //tell user what we are doing printf ( "\nThis program calculates area of saturation of a gas"); printf ( "\nassume: k(incoming gas) = 10 units/unit of time"); printf ( "\nassume: 50% incoming and 50% outgoing gas molecules\n"); //prime loop r = 0; c = 0; //main program loop for(r = 1; r < ROW; r++){ //row count n[r][0] = K + ((n[r-1][1])/2); for(c = 1; c < r; c++){ //column count n[r][c] = ((n[r-1][c-1])/2) + ((n[r-1][c+1])/2); }//end column loop }//end row loop //print loop for(r = 0; r < ROW; r++){ printf("\n %d ", r); for(c = 0; c < 10; c++){ printf(" %3.2lf ",n[r][c]); } } return 0; } //end main