B

B is the father of C and the grandfather of C++. The following code may or may not work. To the best of my knowledge, there is no runable B compiler in existence anywhere. It originally ran on the Bell Labs Honeywell system. I'm not sure it was ever available anywhere else. Because the following program has never been tested you can assume that it is not 100% correct. However, since locating a running B compiler is not a likely possiblity, I am including this here so you can see what the language looked like. As you can see, it is virtually indisinguishable from C.

The main differences between B and C are these. B variables are untyped. local variables are declared with the "auto" keyword rather than a type. There is no "for" loop, only while loops. Character constants can be from one to four characters long, and are stored in 4-byte integers (36 rather than 32 bits as I recall). There is no stdio library. The output functions are part of the language. To output a string, one must do several "putchar" calls, each one of which outputs from 0 to 4 characters. Instead of \n the newline character is represented by *n.

/*//////////////////////////////////////////////////////// // Name: Peter M. Maurer // Program: Sieve of Eratosthenes // Due: Never // Language: B ////////////////////////////////////////////////////////*/ main() { /* define the sieve data structure */ auto Candidates[1000],i,j; i = 0; while (i<1000) { /* everything is potentially prime until proven otherwise*/ Candidates[i] = 1; i++; } /* Neither 1 nor 0 is prime, so flag them off*/ Candidates[0] = 0; Candidates[1] = 0; /* start the sieve with the integer 0*/ i = 0; while (i<1000) { /* advance to the next un-crossed out number.*/ /* this number must be a prime*/ while (i<1000 & Candidates[i] == 0) { i++; } /* insure against running off the end of the data structure*/ if (i<1000) { /* cross out all multiples of the prime, starting with 2*p.*/ j = 2; while (j*i < 1000) { Candidates[j*i] = 0; j++; } /* advance to the next candidate*/ i++; } } /* all uncrossed-out numbers are prime (and only those numbers)*/ /* print all primes*/ i = 0; while (i<1000) { if (Candidates[i] != 0) { putnumb(i); putchar(' is '); putchar('prim'); putchar('e*n'); } i++; } }

Click Here for the actual code.