Слайд 1System programming
Lecture #1
Artamonov E.B.
Слайд 2Language С: the general characteristic, historical information, the basic advantages
Language С is the general purpose programming language. Occurrence of
him is closely connected to creation of operational system UNIX for he was developed specially for this system and on him the most part of system software UNIX is written. However language С is not focused on work only in one operational system or by any concrete machine.
Слайд 3Basic properties of language С:
a wide set of managing
designs for the organization of cycles and the conditional transitions
providing an opportunity of a spelling of flexible and well structured programs;
the big set of operators and operations, many of which suppose direct translation in a machine code;
variety of primitive types of the data, including an opportunity of management in length of integer and material variables;
presence of means for designing new aggregated types of the data;
Слайд 4Basic properties of language С:
an opportunity of direct work with
machine addresses through the device of indexes;
presence of the preprocessor,
allowing to make change to the text of the program directly ahead of its compilation;
block structure of a program code, an opportunity of work with various classes of memory and means for modular programming
Слайд 5Preparation for performance and performance of programs
Language C concerns
to number compiling programming languages. It means, that preparation for
performance of the С-program includes the following stages:
input of the initial text of the program in a file by means of any editor of texts (the name of a file, as a rule, has standard expansion);
compilation of the program, i.e. transformation of her description in the source language in a semantic equivalent on a computer language, named the objective module (the name of a file in which the result of compilation is located, usually has expansion "OBJ");
construction of the loading module ready to performance from objective modules, including modules from external libraries (the file containing the ready program, has a name with expansion "EXE").
Слайд 6Elements of language C
THE ALPHABET
Letters and figures
- the
big letters of the latin alphabet
A B C D E
F G H I J K L M
N O P Q R S T U V W X Y Z
- small letters of the latin alphabet
a b c d e f g h i j k l m
n o p q r s t u v w x y z
decimal figures
0123456789
Слайд 7Elements of language C
THE ALPHABET
Special symbols
blank! " *
% and ' () * +,-./:; ? [\] ^ _
{|} ~
Names of objects programs (identifiers)
Identifiers in language С are sequences of letters and the figures, beginning with the letter, and the symbol of underlining (_) is considered by the compiler as the letter. The big and small letters of the latin alphabet are considered various. Length of the identifier be formal can any.
Слайд 8Elements of language C
Key words
Key words are the
predetermined identifiers having special values. Names of any objects of
the program should not coincide with the following reserved key words:
types of the data
char float short typedef void
double int signed union
enum long struct unsigned
classes of memory
auto extern register static
Слайд 9Elements of language C
Key words
operators
break
default for return while
case
do goto sizeof
continue else if switch
special
const far huge pascal
cdecl fortran near volatile
Слайд 10Elements of language C
Comments
Comments are understood as the
sequences of symbols ignored by the compiler. Comments have the
following form:
/* Characters */
where Characters there is an any combination of any printed symbols ASCII.
Слайд 11Elements of language C
Constants
Constants in language С can
be numbers (the whole and material), symbols and lines of
symbols which is allowable to use in the program in sense of their values. Value of any constant cannot be changed during work of the program. Special instructions of language enable to give to constants of any type symbolical names.
Слайд 12Elements of language C
Operations and expressions
It is necessary
to understand the actions which are carried out by the
program above objects determined in her as operations. For a designation of operations some standard combinations of special symbols from the alphabet of language are used. The objects of the program participating in operation, refer to as operands. Any combination of one or greater number of operands and symbols of the operations, giving a unique value, forms expression. Any expression, coming to an end a semicolon, is the operator. The set of all operations of language С is convenient for dividing into eight following groups:
Слайд 13Elements of language C
arithmetic operations
+ - * / %
++--
operations of the relation
==! = =
logic operations
!
|| &&
bit-by-bit operations
~ <>> & | ^
operations of giving
= + = - = * = / = % = <<=>> = and = ^ = | =
Слайд 14Elements of language C
operations above files
[]
operations above structures
and associations
->
other operations
?:, syzeof (type specifier) ()
Слайд 15Elements of language C
Operators
The elementary operator of language
С is any expression, coming to an end a semicolon.
In particular, separately worth semicolon is interpreted by the compiler as the zero - operator. The most significant group of operators is formed with instructions (operators) of management of process of performance of the program. To them concern:
Слайд 16Elements of language C
- operators of a cycle
for
(; ; )
statement;
while (expression)
statement;
do
statement
while (expression);
Слайд 17Elements of language C
the conditional operator and the switch
if (expression)
statement1
switch (expression)
{>
..
..
..
>
..
..
..
>}
Слайд 18Elements of language C
operators of transfer of management
goto break
continue return
Here expression there is an any correct expression
of language С (C++), and through statement it is designated simple or compound the operator whom, in particular, can be and any operator of management (see lower). The last means, that the investment of operators of management each other is allowable. Elements of designs of language, prisoners in angular brackets (<>), are not obligatory and can be lowered. One or several operators made in braces, the compound operator or the block form. The semicolon after a closing bracket thus is not put.
Слайд 19Elements of language C
Descriptions
Descriptions in language С are
the lines of the program determining names and the characteristics
of functions, variable, types and the symbolical constants used in the program.
General structure of the program
Any program in language С represents set of the functions which are carrying out the basic work on realization of some algorithm. Each of these functions, in turn, is an independent set of descriptions and the operators made between heading of function and her end. That function with which performance of the program begins, refers to as the main function. She should have the predetermined name main ().