Concepts of Programming Languages

(Sean Pound) #1

78 Chapter 2 Evolution of the Major Programming Languages


and switch statements, in its assigning operators, and in its treatment of
pointers.
The only “standard” for C in its first decade and a half was the book by
Kernighan and Ritchie (1978).^11 Over that time span, the language slowly
evolved, with different implementors adding different features. In 1989, ANSI
produced an official description of C (ANSI, 1989), which included many of
the features that implementors had already incorporated into the language.
This standard was updated in 1999 (ISO, 1999). This later version includes a
few significant changes to the language. Among these are a complex data type,
a Boolean data type, and C++-style comments (//). We will refer to the 1989
version, which has long been called ANSI C, as C89; we will refer to the 1999
version as C99.

2.12.2.2 Evaluation
C has adequate control statements and data-structuring facilities to allow its
use in many application areas. It also has a rich set of operators that provide a
high degree of expressiveness.
One of the most important reasons why C is both liked and disliked is its
lack of complete type checking. For example, in versions before C99, functions
could be written for which parameters were not type checked. Those who like
C appreciate the flexibility; those who do not like it find it too insecure. A major
reason for its great increase in popularity in the 1980s was that a compiler for it
was part of the widely used UNIX operating system. This inclusion in UNIX
provided an essentially free and quite good compiler that was available to pro-
grammers on many different kinds of computers.
The following is an example of a C program:

/* C Example Program
Input: An integer, listlen, where listlen is less than
100, followed by listlen-integer values
Output: The number of input values that are greater than
the average of all input values */
int main (){
int intlist[99], listlen, counter, sum, average, result;
sum = 0;
result = 0;
scanf("%d", &listlen);
if ((listlen > 0) && (listlen < 100)) {
/* Read input into an array and compute the sum */
for (counter = 0; counter < listlen; counter++) {
scanf("%d", &intlist[counter]);
sum += intlist[counter];
}


  1. This language is often referred to as “K & R C.”

Free download pdf