TYPES OF PROGRAMMING LANGUAGES
There are many different languages can be used to program a computer. The most basic of these is machine language--a collection of very detailed, cryptic instructions that control the computer’s internal circuitry. This is the natural dialect of the computer. Very few computer programs are actually written in machine language, however, for two significant reasons: First, because machine language is very cumbersome to work with and second, because every different type of computer has its own unique instruction set. Thus, a machine-language program written for one type of computer cannot be run on another type of computer without significant alterations. Usually, a computer program will be written in some high-level language, whose instruction set is more compatible with human languages and human thought processes. Most of these are general-purpose languages such as C. (Some other popular general-purpose languages are Pascal, Fortran and BASIC.) There are also various special-purpose languages that are specifically designed for some particular type of application. Some common examples are CSMP and SIMAN, which are special-purpose simulation languages, and LISP, a Zistprocessing language that is widely used for artificial intelligence applications. As a rule, a single instruction in a high-level language will be equivalent to several instructions in machine language. This greatly simplifies the task of writing complete, correct programs. Furthermore, the rules for programming in a particular high-level language are much the same for all computers, so that a program written for one computer can generally be run on many different computers with little or no alteration. Thus, we see that a high-level language offers three significant advantages over machine language: simplicity, uniformity and portability (i.e., machine independence). A program that is written in a high-level language must, however, be translated into machine language before it can be executed. This is known as compilation or interpretation, depending on how it is carried out. (Compilers translate the entire program into machine language before executing any of the instructions. Interpreters, on the other hand, proceed through a program by translating and then executing single instructions or small groups of instructions.) In either case, the translation is carried out automatically within the computer. In fact, inexperienced programmers may not even be aware that this process is taking place, since they typically see only their original high-level program, the input data, and the calculated results. Most implementations of C operate as compilers. A compiler or interpreter is itself a computer program. It accepts a program written in a high-level language (e.g., C) as input, and generates a corresponding machine-language program as output. The original high-level program is called the source program, and the resulting machine-language program is called the object program. Every computer must have its own compiler or interpreter for a particular high-level language. It is generally more convenient to develop a new program using an interpreter rather than a compiler. Once an error-free program has been developed, however, a compiled version will normally execute much faster than an interpreted version.
👉
See Videos More Up to Date ..........
***INTRODUCTION TO C
C is a general-purpose, structured programming language. Its instructions consist of terms that resemble algebraic expressions, augmented by certain English keywords such as if, else, for, do and while. In this respect C resembles other high-level structured programming languages such as Pascal and Fortran. C also contains certain additional features, however, that allow it to be used at a lower level, thus bridging the gap between machine language and the more conventional high-level languages. This flexibility allows C to be used for systems programming (e.g., for writing operating systems) as well as for applications programming (e.g., for writing a program to solve a complicated system of mathematical equations, or for writing a program to bill customers). C is characterized by the ability to write very concise source programs, due in part to the large number of operators included within the language. It has a relatively small instruction set, though actual implementations include extensive library functions which enhance the basic instructions. Furthermore, the language encourages users to write additional library functions of their own. Thus the features and capabilities of the language can easily be extended by the user.
***INTRODUCTORY CONCEPTS
C compilers are commonly available for computers of all sizes, and C interpreters are becoming increasingly common. The compilers are usually compact, and they generate object programs that are small and highly efficient when compared with programs compiled from other high-level languages. The interpreters are less efficient, though they are easier to use when developing a new program. Many programmers begin with an interpreter, and then switch to a compiler once the program has been debugged (i.e., once all of the programming errors have been removed). Another important characteristic of C is that its programs are highly portable, even more so than with other high-level languages. The reason for this is that C relegates most computer-dependent features to its library functions. Thus, every version of C is accompanied by its own set of library functions, which are written for the particular characteristics of the host computer. These library fbnctions are relatively standardized, however, and each individual library function is generally accessed in the same manner from one version of C to another. Therefore, most C programs can be processed on many different computers with little or no alteration.
History of C.
C was originally developed in the 1970s by Dennis Ritchie at Bell Telephone Laboratories, Inc. (now a part of AT&T). It is an outgrowth of two earlier languages, called BCPL and B, which were also developed at Bell Laboratories. C was largely confined to use within Bell Laboratories until 1978, when Brian Kernighan and Ritchie published a definitive description of the language.* The Kernighan and Ritchie description is commonly referred to as “K&R C.” Following the publication of the K&R description, computer professionals, impressed with C’s many desirable features, began to promote the use of the language. By the mid 1980s, the popularity of C had become widespread. Numerous C compilers and interpreters had been written for computers of all sizes, and many commercial application programs had been developed. Moreover, many commercial software products that were originally written in other languages were rewritten in C in order to take advantage of its efficiency and its portability. Early commercial implementations of C differed somewhat from Kernighan and Ritchie’s original definition, resulting in minor incompatibilities between different implementations of the language. These differences diminished the portability that the language attempted to provide. Consequently, the American National Standards Institute** (ANSI committee X3J11) has developed a standardized definition of the C language. Virtually all commercial C compilers and interpreters now adhere to the ANSI standard. Many also provide additional features of their own. In the early 1980s, another high-level programming language, called C++,was developed by Bjarne Stroustrup*** at the Bell Laboratories. C++ is built upon C, and hence all standard C features are available within C++.However, C++ is not merely an extension of C. Rather, it incorporates several new fundamental concepts that form a basis for object-oriented programming--a new programming paradigm that is of interest to professional programmers. We will not describe C++ in this book, except to mention that a knowledge of C is an excellent starting point for learning C++. This book describes the features of C that are included in the ANSI standard and are supported by commercial C compilers and interpreters. The reader who has mastered this material should have no difficulty in customizing a C program to any particular implementation of the language.
***Structure of a C Program
Every C program consists of one or more modules calledfunctions. One of the functions must be called main. The program will always begin by executing the main function, which may access other functions. Any other function definitions must be defined separately, either ahead of or after main (more about this later, in Chaps. 7 and 8).
* Brim W.Kernighan and Dennis M.Ritchie, The CProgramming Language, Prentice-Hall, 1978. ** ANSI Standard X3.159-1989. American National Standards Institute, 1430 Broadway, New York, NY,10018. (See also Brim W. ***Kernighan and Dennis M. Ritchie, The C Programming Language, 2d ed., Prentice-Hall, 1988.) Stroustrup, Bjame, The C++ Programming Language, 2d ed., Addison-Wesley, 1991.
Wait for next up to date...........