Send Close Add comments: (status displays here)
Got it!  This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
The C programming language


1. The C programming language

2. Background
Programming languages had been around since the late 1950s and early 1960s (FORTRAN, LISP, COBOL, ALGOL, etc.).

But until the 1970s, system software (operating systems, telephone network software, etc.) was programming in assembly language.

This was tedious, difficult, time-consuming, and expensive. That was about to change.

3. Which end is up?
One particular problem was the order of bytes for values consisting of more than one byte. A higher level language could handle the endian problems. Today C is considered a low-level language, close to the hardware and memory, but then it was an important innovation.

4. Premier technology companies

5. Kernigan and Ritchie
In 1972, Kernigan and Ritchie , Bell Labs (phone company based research) developed the language C.

It was imperative (procedural or command-based) language.

Initially used to write programs on Unix, it was soon used to rewrite the Unix kernel and most of the operating system.

6. K&R book
The C programming languageThe book by Kernighan Ritchie (1978), known as "K&R", entitled The C programming language (Englewood Cliffs, NJ: Prentice Hall) is still popular today.

7. Hello world
The first program that is often written by a student, and by many programmers using a new language, is a program that outputs a message to the default output, often the "Hello, world" program Kernighan, B. & Ritchie, D. (1978). The C programming language. Englewood Cliffs, NJ: Prentice Hall.. . This is a minimal program that does something that is observable.

The K&R book popularized the idea of a "Hello, world" program as a first program in any programming language.

8. Hello world
Here is the standard "Hello world" program in C.

Here is the C code.

Here is the output of the C code.

Here is the standard "Hello world" program in C using another indentation style.

Here is the C code.

Here is the output of the C code.

Here is the standard "Hello world" program in C using yet another indentation style.

Here is the C code.

This style most closely follows Python and Lua (and other popular languages) and is the style that I use and the style used in (almost all) examples.

Here is the output of the C code.

Here is the standard "Hello world" program in C using another indentation style that is not easy to read.

Here is the C code.

Never use this style!

Here is the output of the C code.


9. Style
Program style is very important.

You should always do similar things in the same way.

You can lose points on your submissions by not using a consistent style.

10. Compilers
C was standardized in 1989 as ANSI C, via ANSI (American National Standards Institute) and the ISO (International Standards Organization) .

It is a popular cross-platform programming language.

The Lua scripting/programming language is implemented in ANSI C.

11. Curly braces
C popularized the use of curly braces for control structures and required parentheses around expressions for if, while, for, etc. Some exceptions to this today or the following.

12. Influences on C
Dennis Ritchie was influenced by the BCPL language.

He first developed the language B. The follow-on was the language C.

13. Error messages
A C source program is first compiled to object code and then linked together.

A separate linking process means that the compiler does not have access to liking information that would provide more meaningful error messages.

The C preprocessor adds to the difficulty in providing meaningful error messages.

14. End of page

15. Acronyms and/or initialisms for this page