11.07.2015 Views

Encyclopedia of Computer Science and Technology

Encyclopedia of Computer Science and Technology

Encyclopedia of Computer Science and Technology

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CCThe C programming language was developed in the early1970s by Dennis Ritchie, who based it on the earlier languagesBCPL <strong>and</strong> B. C was first used on DEC PDP-11computers running the newly developed UNIX operatingsystem, where the language provided a high-level alternativeto the use <strong>of</strong> PDP Assembly language for development<strong>of</strong> the many utilities that give UNIX its flexibility.Since the 1980s, C <strong>and</strong> its descendent, C++, have becomethe most widely used programming languages.Language FeaturesLike the earlier Algol <strong>and</strong> the somewhat later Pascal, Cis a procedural language that reflects the philosophy <strong>of</strong>programming that was gradually taking shape duringthe 1970s (see structured programming). In general,C’s approach can be described as providing the necessaryfeatures for real world computing in a compact <strong>and</strong>efficient form. The language provides the basic controlstructures such as if <strong>and</strong> switch (see branching statements)<strong>and</strong> while, do, <strong>and</strong> for (see loop). The built-indata types provide for integers (int, short, <strong>and</strong> long),floating-point numbers (float <strong>and</strong> double), <strong>and</strong> characters(char). An array <strong>of</strong> any type can be declared, <strong>and</strong> a stringis implemented as an array <strong>of</strong> char (see data types <strong>and</strong>characters <strong>and</strong> strings).Pointers (references to memory locations) are used for avariety <strong>of</strong> purposes, such as for storing <strong>and</strong> retrieving datain an array (see pointers <strong>and</strong> indirection). While theuse <strong>of</strong> pointers can be a bit difficult for beginners to underst<strong>and</strong>,it reflects C’s emphasis as a systems programminglanguage that can “get close to the hardware” in manipulatingmemory.Data <strong>of</strong> different types can be combined into a recordtype called a struct. Thus, for example:struct Employee_Record {char [10] First_Name;char [1] Middle_Initial;char [20] Last_Name;int Employee_Number;} ;(There is also a union, which is a struct where the samestructure can contain one <strong>of</strong> two different data items.)The st<strong>and</strong>ard mathematical <strong>and</strong> logical comparisonoperators are available. There are a couple <strong>of</strong> quirks: theequals comparison operator is = =, while a single equal sign= is an assignment operator. This can create a pitfall for thewary, since the conditionif (Total = 10)printf (“Finished!”);always prints Finished, since the assignment Total = 10returns a value <strong>of</strong> 10 (which not being zero, is “true” <strong>and</strong>satisfies the if condition).C also features an increment ++ <strong>and</strong> decrement - - operator,which is convenient for the common operation <strong>of</strong> raisingor lowering a variable by one in a counting loop. In Cthe following statements are equivalent:65

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!