Subj : Re: Dartmouth BASIC to C To : comp.programming From : Marlene Stebbins Date : Mon Aug 08 2005 10:30 pm John Smith wrote: > Having nothing better to do on a Saturday morning, I was looking at > Kemeny & Kurtz's 1964 manual for BASIC: > > http://www.bitsavers.org/pdf/dartmouth/BASIC_Oct64.pdf > > Below is a C port of the first example program given in the manual. Can > it be improved while preserving, as much as possible, the structure of > the original BASIC program? How about this? #include #include void READ(double *var); double DATA[] = {1.0, 2.0, 4.0, 2.0, -7.0, 5.0, 1.0, 3.0, 4.0, -7.0}; int main(void) { int sys; double A1, A2, A3, A4; double D, X1, X2, B1, B2; READ(&A1); READ(&A2); READ(&A3); READ(&A4); D = A1 * A4 - A3 * A2; if(D == 0.0) { printf("no unique solution\n"); exit(EXIT_SUCCESS); /* hope this makes Gerry Quinn happy :-)*/ } for(sys = 0; sys < 3; sys++) { READ(&B1); READ(&B2); X1 = (B1 * A4 - B2 * A2) / D; X2 = (A1 * B2 - A3 * B1) / D; printf("%f %f\n", X1, X2); } return 0; } void READ(double *var) { static int datum; *var = DATA[datum++]; return; } .