0% found this document useful (0 votes)
35 views3 pages

B Programming Language

B Programming Language

Uploaded by

youssefbouh2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views3 pages

B Programming Language

B Programming Language

Uploaded by

youssefbouh2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

B Programming Language: Overview and

Essentials
1. Introduction
• B is a procedural programming language developed in the late 1960s by Ken
Thompson at Bell Labs.
• Predecessor of the C programming language.
• Key features:
o Minimalist design
o Close to assembly language for systems programming
o Designed for recursive, block-structured programs

2. Basic Syntax
main() {
auto x;
x = 5;
putchar('A');
}

• Statements end with newline or semicolon


• Functions are declared with the function name followed by parentheses

3. Data Types
• Only a few data types:
o int (integer)
o char (character)
o No separate float in early versions
• Example:

auto a, b;
a = 10;
b = 20;

4. Control Flow
• If-Else

Confidential – Oracle Internal


if a > b
putchar('X');
else
putchar('Y');

• Loops

a = 0;
loop:
a = a + 1;
if a < 5 goto loop;

• B uses goto for looping instead of structured loops in early versions

5. Functions
f(x) {
return x + 1;
}

main() {
auto y;
y = f(5);
}

• Functions can return integers


• Local variables declared with auto

6. Input/Output
• Basic I/O using getchar() and putchar()

char c;
c = getchar();
putchar(c);

• No standard library like in C

7. Arrays
auto arr[5];
arr[0] = 10;
arr[1] = 20;

Confidential – Oracle Internal


• Fixed-size arrays
• Array indices start at 0

8. Limitations
• No explicit type declarations for many variables (weak typing)
• Minimal built-in operations
• Designed mainly for system programming on early Unix machines

9. Legacy
• Direct predecessor to C
• Concepts like main(), auto, and putchar() influenced C’s design
• Rarely used today but important historically

10. Resources
• Historical reference: The Evolution of the C Language by Dennis Ritchie
• Early Unix manuals and archives
• Online historical programming resources and retrocomputing communities

Confidential – Oracle Internal

You might also like