Microsoft Store
 

B programming language


 

B was the name of a programming language developed at Bell Labs. It is almost extinct, as it was replaced by the C language.

Example

The following example is from the Users' Reference to B by Ken Thompson:

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

/* The following function will print a non-negative number, n, to

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

the base b, where 2

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

in the ANSCII character set, the digits O to 9 have sequential

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

code values. */

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

printn(n,b) {

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

extrn putchar;

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

auto a;

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

if(a=n/b) /* assignment, not test for equality */

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

printn(a, b); /* recursive */

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

putchar(n%b + '0');

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

}

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

~ ~ ~ ~ ~ ~ ~ ~ ~ ~