C (programming language): Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Pat Palmer
No edit summary
imported>Pat Palmer
(reword of opening, try 5)
Line 1: Line 1:
C is a general-purpose, procedural [[computer]] [[programming language]] which is still in use more than thirty years after its creation.  '''C''' was developed in 1972 by [[Dennis Ritchie]] and [[Brian Kernighan]] (then of [[Bell Laboratories]]) for use with the [[Unix]] operating system<ref name="K&R">Kernighan, B. and Ritchie, D.: The C Programming Language. Prentice Hall, 1978.
C is a general-purpose, procedural [[computer]] [[programming language]] which is still in use more than thirty years after its creation.  '''C''' was developed in 1972 by [[Dennis Ritchie]] and [[Brian Kernighan]] (then of [[Bell Laboratories]]) for use with the [[Unix]] operating system<ref name="K&R">Kernighan, B. and Ritchie, D.: The C Programming Language. Prentice Hall, 1978.
*The original language definition before standardization.</ref>. The language was later implemented for many different computer platforms and has been standardized by ANSI and ISO.  
*The original language definition before standardization.</ref>. The language was later implemented for many different computer platforms and has been standardized by ANSI and ISO. As of 2007, versions of C is still used, especially for writing [[operating system]] software and [[embedded]] programs (for gadgets such as smart phones).  The syntax and scope rules of C were also adopted by several later programming languages, including [[C++]], [[Java]],[[Javascript]] and [[C sharp]].  
 
The syntax and scope rules of C subsequently influenced an entire "family" of programming languages, beginning with [[C++]] (designed by [[Bjarne Stroustroup]] as an enhancement to C) and also including [[Java]],[[Javascript]] and [[C sharp]].  As of 2007, versions of C is still used for writing some [[operating system]] software, and especially for [[embedded]] programs (for gadgets such as smart phones).


==Syntax==
==Syntax==

Revision as of 15:39, 25 April 2007

C is a general-purpose, procedural computer programming language which is still in use more than thirty years after its creation. C was developed in 1972 by Dennis Ritchie and Brian Kernighan (then of Bell Laboratories) for use with the Unix operating system[1]. The language was later implemented for many different computer platforms and has been standardized by ANSI and ISO. As of 2007, versions of C is still used, especially for writing operating system software and embedded programs (for gadgets such as smart phones). The syntax and scope rules of C were also adopted by several later programming languages, including C++, Java,Javascript and C sharp.

Syntax

Hello World

#include <stdio.h>

int main(void) {
   printf("Hello, world!\n");
   return 0;
}

Analysis of the example

The above Hello World program is probably the most widely recreated piece of software ever as it is used by many programming languages books and articles as a cursory introduction into a language's syntax. It was introduced in the book The C Programming Language[1].

#include <stdio.h> tells the precompiler to include the contents of the header file stdio.h, which declares standard input and output functions into the program before compiling.

int main(void) { tells the compiler that there is a function named main which expects no parameters (void) and will return a integer number to the caller (int). Due to a standard convention of the language, main is the first function called after the execution environment of the program has been set up. The opening curly brace following int main(void) denotes the beginning of the function.

printf("Hello, world!\n"); will make the program output Hello, world! and a new line (\n) on the screen. printf is itself a function similar to main but predefined in a library (libc) and linked into the program at compile time or runtime. The trailing semicolon is the end of statement marker in C.

return 0; defines the value to be returned from main and leaves the function back to its caller, some standard C startup code. After some additional cleanup that code will pass the 0 on to the operating system, to which it means 'success'.

} signals the end of the function definition to the compiler.

Derivatives

C has spawned many derivatives, including C++, Objective-C, and C#, which are commonly used in programming applications for Linux, Mac OS X, Windows and other operating systems.

References

  1. 1.0 1.1 Kernighan, B. and Ritchie, D.: The C Programming Language. Prentice Hall, 1978.
    • The original language definition before standardization.

See also

External links