Вы находитесь на странице: 1из 73

1.

1.1.
1.1.1.
.
1. , (.1).
,
. ,
, .
1

ABCDEFGHIJKLMNOPQRS
TUVWXYZ

abcdefghijklmnopqrstuvwx
yz

2. (.2).
2

0123456789

3. (. 3).
, -
.
2

<

'

>

&

"

4. . : ,
, , , .
, ,
.
( ).
5. ,
, .. ,
.
(\) (
) (.4).
4

\a

007

\b

008

\t

009

\n

00A

\v

00B

\r

00C

\f

00D

\"

022

\'

027

\0

000

\\

05C

\ddd

\xddd

\ddd \xddd ( d )

.
:
\r - ,

\015 - ,
\x00D - .
,
.
\n ( ) \010 \xA,
,

. :
"ABCDE\x009FGH"
, ABCDE FGH, 8-
,
"ABCDE\x09FGH", ABCDE=|=GH,
\x09F "=+=".
, ,
(.. .4)
, ,
. :
\h h .
,
(\) . (\) (\n),
, .
.
1.1.2.
.
: , ,
.
: , ,
: ,
.
,
(
).

( ,
).
0 0
(
: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)

16

020

0x10

127

0117

0x2B

240

0360

0XF0

, "-"
( ). :
-0x2A, -088, -16 .
, ,
, .
:
- ,
int () long ( ) .
32768, int long.
- int, unsigned int
( ), long unsigned long
5.
5

0x0 - 0x7FFF

0 - 077777

int

0X8000 - 0XFFFF

0100000 - 0177777

unsigned int

0X10000 - 0X7FFFFFFF

0200000 - 017777777777

long

0X80000000 - 0XFFFFFFFF

020000000000 - 037777777777

unsigned long

long,
"l" "L". :
5l, 6l, 128L, 0105L, OX2A11L.
- ,
. :
[ ].[ ] [ |e [+|-] ] .
() .

( double).

,
.
: 115.75, 1.5-2, -0.025, .075, -0.852
- .
,
.
. :
' '- ,
'Q'- Q ,
'\n' - ,
'\\' - ,
'\v' - .
int .
() - (
) (") .
: " N 35", " ", "YZPT ".
, , ("), (\)

.
. ,
" \n N 35" "" , "N
35" .
.
,
\0.
char[] . ,
. ,
1, ( )
.
. .

. ,
, . :
" \n
"

" " .
( ) .
,
, .

.
1.1.3.
,
, , .

.
(_).
, . : abc, ABC,
A128B, a128b .
,
, 31 .
, , ..
.
.
, ,
.
, (_)
,
, , ,
() , ,
, ..
.
, ,
,
(, ,
).
1.1.4.
- ,
.
.

auto

double

int

struct

break

else

long

switch

register

tupedef

char

extern

return

void

case

float

unsigned

default

for

signed

union

do

if

sizeof

volatile

continue

enum

short

while

,
:
_asm, fortran, near, far, cdecl, huge, paskal, interrupt .
far, huge, near
. _asm, cdelc, fortran, pascal
,
.
.
1.1.5.
- , ,
, , . ,

, (/* */). ,
, . :
/* */
/* */

/*

, ,
, ,
*/

.
/* /* */ */

/* */ */

1.2.
(PL1, FORTRAN, .)
,
.
:

[--]

[=] [, [= ] ]...

-
, ( ).
- ,
. ,
() .
- ,
() .
- :
auto, extern, register, static, ,
, , ,
, .., .
1.2.1

:

char

float

int

double

short

long

double

long
signed
unsigned

.
const -. const
, ..
. , const
-, int. const
(, , , ),
, , ..
.
:
const double A=2.128E-2;
const B=286; ( const int B=286)

.
1.2.2.
,
,
(. 6).
6

char

-128 127

int

IBM XT,AT,SX,DX 2

short

-32768 32767

long

-2 147 483 648 2 147 483 647

unsigned shar

o 0 255

unsigned int IBM XT,AT,SX,DX 2


unsigned short

0 65535

unsigned long

0 4 294 967 295

, signed unsigned . ,
, ..,
unsigned, ,
.
unsigned . ,
signed unsigned
, int. :
unsigned int n;
unsigned int b;
int c;

signed

int c

);

unsigned d;

unsigned int d

);

signed f;

signed

).

int f

, - char (
) .
char ( 1 ),
. ,
unsigned char,
127.
:
- int unsigned int.
signed int
, . , 16-

2- , 32-
4- , .. int short int, long int
. ,
.

sizeof , -.
:
a = sizeof(int);
b = sizeof(long int);
c = sizeof(unsigned long);
d = sizeof(short);

,
unsigned. u U ,
.
:
0xA8C

(int

signed

);

01786l

(long signed

);

0xF7u

(int

unsigned );

1.2.3.
,
- : float, double, long double ( long double
).
- float 4 . 1
, 8 23 . ,
1, ,
3.14E-38 3.14E+38.
double 8 . float.
: 1 , 11 52
.
1.7E-308 1.7E+308.
:
float f, a, b;
double x,y;

1.2.4.
- , (
, , ,
). , ,
, .
, ,
,
( ). :
- [ ] * .
- ,
, ( ). -
void, ,
. , void,
. ,

, ,
.
.

const, near, far, huge. const ,
. ,
,
.
.
near, far, huge.
:
unsigned int * a; /*

unsigned int ( ) */
double * x;

/*

char * fuffer ;

/*

*/

fuffer

char */

double nomer;
void *addres;
addres = & nomer;
(double *)addres ++;
/* addres .
(& - ).

, ,
,
,
,

(double *)

addres double, .
*/
const * dr;
/* dr , ..
,
, , . */
unsigned char * const w = &obj.
/* w char
unsigned. ,
w

. */

1.2.5.
, ,
.
enum
.
1. enum [--] {-} [,...];
2. enum -- [,..];

, -.
.

. int. ,
,
int.
enum
.
1 .
--, ,
, .
.
.
- :

[= ]
.
enum .
0, - 1
.. .
, , ,
. int
, .
, 1,
.
:
1. .
2.
,
.
3. ,
.
4. .
:
enum week { SUB = 0,

/*

*/

VOS = 0,

/*

*/

POND,

/*

*/

VTOR,

/*

*/

SRED,

/*

*/

HETV,

/*

*/

PJAT

/*

*/

rab_ned ;

week,
, rab_ned week.
,
- .
.
- ,
.
:

enum week rab1;


typedef
,
.
typedef.
, , ,
.
1.2.6.
- (double, float, int ..).

. :
- [ - ];
- [ ];
- .
- .
void.
- .
-
:
- ,
- ,
- , .
,
, .
- ,
- .
-
,
-, - .. ,
0.
:
int a[2][3]; /*
a[0][0]

a[0][1] a[0][2]

a[1][0]

a[1][1] a[1][2]

*/

double b[10]; /* 10

double */

int w[3][3] = { { 2, 3, 4 },
{ 3, 4, 8 },
{ 1, 0, 9 } };

w[3][3]. , ,
,
.
,
(PL1 ..), .
.
.

, .
:
int s[2][3];
s[0],
s.
int b[2][3][4];
b , , b[1][2]
, b[1] 3 4.
b[2][4], , ,
.
.
char str[] = " ";
, ,
'\0'.
1.2.7.
C - , ,
. , ,
. :
struct { }
.
:
- ;

- , .
.
:
struct { double x,y; } s1, s2, sm[9];
struct {

int

year;

char

moth, day; } date1, date2;

s1, s2 ,
. sm .
date1, date2 year, moth, day. >p>
,
. .
:
struct { ; };
.
student :
struct student { char name[25];
int
char

id, age;
prp;

};


:
struct -;
:
struct studeut st1,st2;
.
.
struct node { int data;
struct node * next; }

st1_node;

node ,
, .. next.
, .. node ,

node, ,
, .

, :
st1.name="";
st2.id=st1.id;
st1_node.data=st1.age;

1.2.8. ()
,
( ) .
:
union {

1;
...
n; };

,
, .. .
,
, .
, .
, .
:
- ,
;
- ,
.
, , ,
.
,
.
, .
:
union {

char

fio[30];

union {

char

adres[80];

int

vozrast;

int

telefon;

} inform;

int ax;
char al[2];

ua;

infor union
, .. inform.fio,
. ua
ua.al[0] ua.al[1] ua.ax .
1.2.9.
,
. .
.
:
struct { unsigned 1 :

1;

unsigned 2 :

2;

- .
, .
.
:
struct { unsigned a1 :

1;

unsigned a2 :

2;

unsigned a3 :

5;

unsigned a4 :

2;

} prim;

.
,
.
, .
,
.
1.2.10.

,
. , ,
. ,
, .
.
,
.
struct figure {
double area,perimetr;

/*

*/

int type;

/*

*/

union

/* */
{ double radius;

/*

*/

double a[2];

/*

*/

double b[3];

/*

*/

} geom_fig;
}

fig1, fig2

figure : area,
perimetr, type. type ,
, geom_fig
. ,

( type).
, type int,
. ,
enum figure_chess { CIRCLE,
BOX,
TRIANGLE

} ;

CIRCLE, BOX, TRIANGLE 0, 1, 2.


type :
enum figure_chess type;

, , ,
figure.type = 40;

:
, .
, :
struct { ;
;
union { 1 ;
2 ;
:::
n ;
} - ;
} - ;

helth_record
struct { /* */
char

name [25];

/*

*/

int

age;

/*

*/

char

sex;

/*

*/

/*

/*

( )

*/
*/

enum merital_status ins;


/* */
union

/*

*/

/* */
struct {

/* */
char marripge_date[8];
char spouse_name[25];
int
}

no_children;

marriage_info;

/* */
char date_divorced[8];
}

marital_info;

} health_record;

enum marital_status { SINGLE, /*


MARRIGO, /*

*/
*/

DIVOREED /* */
} ;

:
helth_record.neme,
helth_record.ins,
helth_record.marriage_info.marriage_date .

1.2.11.
, ,
. ,


(), ( ) ( ).
, , ,
, - . ,
:
, .
,
,
.
, :
- ,
- .
(
) ( ).

. ,
. ,
.
,
" ", .

1. , .
2. ,
.
3. ,
,
.
4. .
:
int

* ( * comp [10]) ();

comp (1), (2)


(3) (4), (5) (6).
char
7

* ( * ( * var ) () ) [10];
6

var (1) (2) (3)


(4) (5) 10 , (6)
char.
, .
. -
, ,
. -
typedef.
typedef,
, ,
.
, typedef,
, . typedef
, ,
, .
:
typedef double (* MATH)( );
/* MATH - ,
, double

*/

MATH cos;
/* cos

double

*/

/*

*/

double (* cos)( );

typedef char FIO[40]


/* FIO -

*/

FIO person;
/*

person

/*

*/
*/

char person[40];

(MATH FIO).
, :
, ,
sizeof ( ).
, ,
.
:
- -;
- - ,
, . (*)
, [] () . , ,
.
.
,
.
1.2.12.
,
. "=" .
1: = ;
2: = { - };

1 ,
2 - .
:
char tol = 'N';
tol 'N'.
const long megabute = (1024 * 1024);
megabute
.
static int b[2][2] = {1,2,3,4};
b
.
:
static int b[2][2] = { { 1,2 }, { 3,4 } };

static int b[3[] = { { 1,2 }, { 3,4 } };
,
0, ..
static int b[2][2] = { { 1,2 }, { 3 } };
1 2, 3 0.
,
.
:
struct complex { double real;
double imag; }

comp [2][3] =

{ { {1,1}, {2,3}, {4,5} },


{ {6,7}, {8,9}, {10,11} } };

comp
, real imag.
struct complex comp2 [2][3] =

{ {1,1},{2,3},{4,5}, {6,7},{8,9},{10,11} };


:
- - comp2;
- - comp2[0].
1,1 ;
- ( 1) ,
, comp[0]
;
- {2,3} comp[1],
;
- {4,5}
3 comp2 .

.
:
union tab { unsigned char name[10];
int tab1;
}

pers

{'A','H','T','O','H'};

pers.name, ,
.
, .

.
char stroka[ ] = "";
7 , ()
'\0', .
, , ,
, .
stroka ,
.
char stroka[5] = "";

stroka , '' '\0'


.
, ,
.
, tab :
union tab pers1 = "";
, , :
'','','','','','\0',
.

1.3.
1.3.1.
,
, . ,
.
.
, .
,
, .

. ,
, , .
- , , , , ,
,
, . ,
, .
.
,
. int, long, unsigned int,
unsigned long, .
int. double.
, ,
char,
.

char.
, .
, .

, ,
.
. ,
.
:
-
;
- enum
.
. int, ;
- struct union ,
;
- , , ,
;
- , , ,
. -
. ,
, .
, ,
.
- , , ,
, .
, .
,
.
,
:
-1 ([ ])
-1 (,
).
. , ,
.
:
-1 [ -2 ]
,
, -1 -2.
-1 - , , , -2 . , ,

. -1
, -2 . -2
.
, .


(*).
, , ,
,
, ,
. , , arr
double.
double arr[10];
, i- arr
rr[i], , , i[a]. i
double i- arr .
arr,
i- . ,
.. arr .
, arr[i] ( i[arr]) i .
.
- , . ,
.

:
-1 [ -2 ][ -3 ] ...
, ..
:
-1 [ -2 ]
,
-3 ..
. , ,
.
:
int mass [2][5][3];
mass[1][2][2].

1. mass[1]. 1
, 53
, int.
mass. (53)
mass.
2. 2 int,
, mass [1].
3. - int, 2
int mass [1][2].
4. , .
int.
mass [1][2],
int. mass [1]
.
,
.
. :
. ,
-> .
struct union,
- .
, -
.
. ,
, (->),
,
(*), , ..
->

(* ) .
, .
:
struct tree { float
int
struct tree

num;
spisoc[5];
*left;

tr[5] , elem ;

elem.left = & elem;

(.) left
elem. left elem
elem, .. elem
.
() .
:
( - ) .

.
.
:
int i;
bouble x;
b = (double)i+2.0;

i
, .
- , .
,
, , ,
, sizeof .

:
1.
(,) .
2. "" (&) .
.
( ),
( ) ( ).

:
-- .
, :

1 -- 2 .
,
(?) (:), :
1 ? 2 : 3 .
. , ,
, .
:
- ( );
~ ();
! ;
* ( );
& ;
+ ;
++ ();
-- ();
sizeof .
.

.
( ),
. (
), , .
, , .7,
.
7

<<

>>

<

<=

>=

==

!=

&

&&

||

*=

/=

%=

-=

+=

<<=

>>=

&=

|=

^=

,
( const),
:
- , , ,
;

- , ;
- (->) (.),
;
- (*), ,
;
-
.
, (*), (&), (!), (+) \
.
1.3.2.
,

, .
.
.
1. float double.
2. long double, .
3. double, double.
4. char short int.
5. unsigned char unsigned short unsigned int.
6. unsigned long, unsigned long.
7. long, long.
8. unsigned int, .
, ,
, .
:
double

ft,sd;

unsigned char

ch;

unsigned long

in;

int

i;

....

sd=ft*(i+ch/in);


. ch unsigned int ( 5).
unsigned long ( 6). i
unsigned long ,
unsigned long. double ( 3)
double.
1.3.3.
(-) .
.
.
:
double

u = 5;

u = -u;

/* u ,
.. u

-5

*/

"" (!) 0,
( ), 1, (0). int.
.
:
int t, z=0;
t=!z;

t 1, z 0
().
(~) .
.
, .
:
char

b = '9';

unsigned char

f;

b = ~f;

'9' 39. ~f
6, ''.
1.3.4.
.
(*)
. . ,
. ,
. , .
, :
- ;
- ,
;
- , ,
;
- , .
(&) .
. "",
,
. . ,
, .
,
, register.
:
int t, f=0,

* adress;

adress = &t; /* adress,


, t */
* adress =f; /* ,
adress,
f,
t=f;

..

..
t=0;

0 ,
*/

1.3.5. sizeof
sizeof
. sizeof :

sizeof() .
, ,
. , void,
.
,
(.. ), ,
.
sizeof
,
,
, .
, ,
.
:
struct

{ char

h;

int

b;

double f;
} str;
int a1;
a1

= sizeof(str);

1 , 12,
, , str 7.
,
h 1 , 1 b
( 2 IBM PC AT /286/287),
f (4
),
5 .

, ..
:
struct

{ double f;
int

b;

char

h;

} str;

1.3.6.
(*), (/)
(%). (%) . ,
,
.
.
(*) .
int

i=5;

float f=0.2;
double g,z;
g=f*i;

i f double,
g.
(/) .
, .
.
int i=49, j=10,

n, m;

n = i/j;

/*

*/

m = i/(-j);

/*

-4

*/

(%) .
.
. , .
int n = 49, m = 10, i, j, k, l;
i = n % m;

/*

*/

j = n % (-m);

/*

*/

k = (-n) % m;

/*

-9

*/

l = (-n) % (-m);

/*

-9

*/

1.3.7.
(+) (-).
.

. ,
,
. ,
.
.
:
int

i=30000, j=30000, k;
k=i+j;

k -5536.
.
,
- .
,
, , .
,
, ,
.
, .
(-) .
:
1. .
2. .
3. , - .
, ,
, .
:
double d[10],* u;
int i;
u = d+2;

/*

*/

i = u-d;

/*

1.3.8.

*/

(<<) (>>)
, . .
.
.
. unsigned,
.
. ,
.
, ,
. ,
, .
, 2,
, 2
, .
:
int

i=0x1234, j,

k ;

k = i<<4 ;

/*

k = 0x0234

*/

j = i<<8 ;

/*

j = 0x3400

*/

i = j>>8 ;

/*

i = 0x0034

*/

1.3.9.
: "" (&),
"" (|), "
" (^).
.
, -
.
(&)
. ,
1, 0.
(|)
. ( )
1, 1,
0.
(^)
. 0,
1, 1,
, .. 1 0, 0.
.

int

i=0x45FF,

/*

i= 0100 0101 1111 1111

*/

j= 0000 0000 1111 1111

*/

r = i^j;

/* r=0x4500 = 0100 0101 0000 0000

*/

r = i|j;

/* r=0x45FF = 0100 0101 0000 0000

*/

r = i&j;

/* r=0x00FF = 0000 0000 1111 1111

j=0x00FF;
char r;

*/

1.3.10.
(&&)
(||). ,
,
.
.
, ,
.
.
.
0 1, int.
(&&) 1,
. 0, 0.
0, .
(||) .
0, 0, -
, 1.
, .
1.3.11.
(,)
,
. .
, .
.
. , ,
, ,
.
1.3.12.
- ,
:

-1 ? -2 : -3
-1 .
0. -1 0,
-2 . -1
0, -3 .
, -2, -3, .
-2 -3, .
1. -2 -3 (,
), .
.
2. -2 -3 ,
, ,
.
3. void, void.
4. ,
vold, vold,
.
5. ,
0, .
:
max = (d<=b) ? b : d;
max d b.
1.3.13.
(++) (--)
.
.
.
() . .
, .

(), ,
() , .
( ),

.
( ),
,
.

:
int t=1, s=2, z, f;
z=(t++)*5;

t*5, t. z=5,
t=2.
f=(++s)/3;

s , .
s=3, f=1.
,
, .
z++; /* */ ++z;
1.3.14.
,
.
, .
.
:
int t;
char f;
long z;
t=f+z;

f long, f+z ,
int t.
1.3.15.
, ,
.
:
(-1) ( ) = (-2) .

:

(-1) = (-1) ( ) (-2) .


,
, -1
.
,
. (+=)
(-=) , .
:
double

arr[4]={ 2.0, 3.3, 5.2, 7.5 } ;

double

b=3.0;

b+=arr[2];

/*

b=b+arr[2]

*/

arr[3]/=b+1;

/*

arr[3]=arr[3]/(b+1)

*/

,
,
.
1.3.16.
.
1.
. 8.
8

() [] . ->

- ~ ! * & ++ -sizeof

*/%

+-

<< >>

< > <= >=

== !=

()

&

10

11

&&

12

||

13

?:

14

= *= /= %= +=

-= &= |= >>=

<<= ^=

15

1.3.17.
,
.
, ( ).
, . ,
:
prog (a,a=k*2);
, ,
.

,
, .
, i*j+(j++)+(--i)
.
.
1. ,
.
2. ,
.
1.3.18.

:
-
( );
- ,
;
- .

, .
, ,
, .
, .
.
, .
, .
,
.
]
, long int unsigned
long int float, .
.
.

.
,
. , , ,
( 1), ..
, .
,
signed long, signed long
. unsigned long float, double long double
, ,
, long.
. float double
. double long double float c
. float,
, .

long ( ),
long .
long, .
float, double long double unsigned long
, ,
, long.
.
.
- .
void ,
void .

.
:
- ,
, ;
- , ,
, , .
:
- , ,
( );
- ,
( ,
), .
. ,
, , (
"") .
,

.
.
float double, char short int,
unsigned char unsigned short unsigned int.
.
,
.
.
, :
( - ) .
- ,
.
:
int

i=2;

long

l=2;

double

d;

float

f;

d=(double)i * (double)l;

f=(float)d;

i,l,d
.
1.4.
:
- , if switch;
- (for,while,do while);
- (break, continue, return, goto);
- ( "", ).

. ,
.
, ,
";".
1.4.1.
, , .
.
, , ,
. , ,
.
.
:
++ i;
, i
.
a=cos(b * 5);
,
.
a(x,y);
.
1.4.2.

.
. :
- do, for, while, if , ,
;
- .
, .
. ,
, .
:
int main ( )
{
:
{ if (...) goto a;

/* */

{ ...
}
a:;

}
return 0;

1.4.3.
,
:
{

[o]
:
; [];
:

, .

.
:

int main ()
{
int

q,b;

double t,d;
:
if (...)
{
int

e,g;

double f,q;
:
}
:
return (0);
}

e,g,f,q . ,
q , ..
q main int. ,
return ,
.
1.4.4. if
:
if () -1; [else -2;]
if .
:
- (.. 0), -1.
- (.. 0), -2.
- -2 (
), if .
if ,

.

:
if (i < j)

i++:

else { j = i-3;

i++; }

, -1,
-2 .
if. if
if else if.
,
if, . ,
else if,
else.
:
int main ( )
{
int t=2, b=7, r=3;
if (t>b)
{
if (b < r)

r=b;

}
else r=t;
return (0);
}

r 2.
, if,
:
int main

( )

{
int t=2,b=7,r=3;
if ( a>b )
if ( b < c ) t=b;
else

r=t;

return (0);
}

r 3, else
if, , ,
if.
if:
char ZNAC;
int x,y,z;
:
if (ZNAC == '-') x = y - z;
else

if (ZNAC == '+') x = y + z;
else if (ZNAC == '*') x = y * z;
else if (ZNAC == '/') x = y / z;
else ...

,
if,
.
switch.
1.4.5. switch
switch
. :
switch ( )
{

[]
:
[ case

-1]: [ -1]

[ case

-2]: [ -2]

:
:
[ default: [ ]]
}

, switch ,
, , .
, ,
, .
.
smitch , case
-. ,
,
.
,
.
.
switch .
, case, , ,
default.
, .
switch
.
, switch ,
case,
.
switch :
- ;
- ,
case;
- ,
, case;
- ,
, default,
switch .
switch:
default switch. case
default switch ,
switch. ,
, ,
- switch.
, case,
. break.
, ,
case.

:
int i=2;
switch (i)
{
case 1: i += 2;
case 2: i *= 3;
case 0: i /= 2;
case 4: i -= 5;
default:

switch , case 2.
, i , 6, ,
case 0, case 4, i 3,
-2. , default,
.
,
if, switch.
char ZNAC;
int x,y,z;
switch (ZNAC)
{
case '+':

x = y + z;

break;

case '-':

x = y - z;

break;

case '*':

x = y * z;

break;

case '/':

x = u / z;

break;

default : ;
}

break
switch,
, switch.

, switch switch,
case
.
:
:
switch (a)
{
case 1: b=c; break;
case 2:
switch (d)
{

case 0:

f=s;

break;

case 1:

f=9;

break;

case 2:

f-=9; break;

}
case 3: b-=c; break;
:
}

1.4.6. break
break
switch, do, for, while. break
, .
1.4.7. for
for - .
:
for ( 1 ; 2 ; 3 )
1 ,
. 2 - , ,
. 3 ,
.
for:
1. 1.
2. 2.

3. 2 (), ,
3 2, 2
(), , for.
, . ,
,
.
:
int main()
{ int i,b;
for (i=1; i<10; i++)
b=i*i;
return 0;
}

1 9.
for
, .
:
int main()
{

int top,

bot;

char string[100],

temp;

for ( top=0, bot=100 ; top < bot ; top++, bot--)


{

temp=string[top];
string[bot]=temp;

}
return 0;
}

, ,
top bot. ,
1 3 ,
, .

for .
,
break.
:
for (;;)
{ ...
...

break;

...
}

, for
.
.
:
for (i=0; t[i]<10 ; i++) ;
i
t, 10.
1.4.8. while
while :
while () ;
,
, .
while :
1. .
2. , while
. ,
while.
3. 1.

for (-1; -2; -3) ;
while :

-1;
while (-2)
{

-3;

for, while
. while ,
.
for while ,
.
1.4.9. do while
do while
, .
:
do while ();
do while :
1. ( ).
2. .
3. , do while
. ,
1.
, ,
break.
while do while .
:
int i,j,k;
...
i=0;

j=0;

k=0;

do { i++;
j--;
while (a[k] < i)

k++;

}
while (i<30 && j<-30);

1.4.10. continue
continue, break, ,
,
, .
:
continue;
:
int main()
{

int a,b;
for (a=1,b=0; a<100; b+=a,a++)
{

if (b%2) continue;
...

/*

*/

}
return 0;
}

1 , continue
for, .
continue, break,
.
1.4.11. return
return , ,
, , .
main . :
return [] ;
, ,
. ,
. ,
.
- return,

. .
, void.
, return
, .
:
int sum (int a, int b)
{

renurn (a+b);

sum a b int,
int, , .
return .
:
void prov (int a, double b)
{

double c;
if (a<3) return;
else if (b>10) return;
else { c=a+b;
if ((2*c-b)==11) return;
}
}

return
.
1.4.12. goto
goto
,
.
:
goto -;
...
-: ;

goto , -.
, goto,
, .. -
. - - .
.
goto, .
,
,
.
1.5.1.

-.
,
, .
- ,
. ,
, .
main ( ), ,
, .
( )
( ),
. ( !) .
,
, .

. , ,
, ...
-
( , ), (
) .
, ,
, ,
, .
.
:
int rus (unsigned char r)
{

if (r>='' && c<=' ')


return 1;
else
return 0;

rus, r
unsigned char. , 1,
, 0 .
,
.
main, , .
,

() .
, ,
, ,
. , ,

int rus (unsigned char r); rus (unsigned char);


, ,
, .. .
,
,
#include.
,
, .

. .
, ,

.

" ",
, . , rus
:
int rus (r)
unsigned char r;
{ ...

/*

*/

...

:
[--] [-] -

([--])
{

-- ,
static extern.
.
-
. - , ,
int.
,
, . ,
,
.
return,
. , ,
,
. return
(
return), . ,
, void,
. ,
, return
,
.
-- -
, . - ,

. - (,) (,...),
, . ,
, , ,
.
,
.
, ,
void.

.
.
, , ,
, . ,
int.

register,
int .

.
, ,
.
, ,

.
int, .. char
int. ,
, double.
,
, .
.
- , ,
.
, ,
auto, .. .
.
,
, return
. , ,
.
,
.

,
.
. ,
,
. ,
,
.
:
/*

void change (int x, int y)


{

int k=x;
x=y;
y=k;

*/

x y, ,
,
change, , ,
.
.
:
/*

*/

void change (int *x, int *y)


{

int k=*x;
*x=*y;
*y=k;


,
change (&a,&b);
,
,
. ()
:
[--] [-] - ([-]) [,--];
,
, .
,
,
-, --,
.
, .
,
, .
- , .

.
, ,
.

int,
.
, :
1. , int.
2. ,
.


, , ,
.
, ,
.
static,
static. ,
extern.
:
- ([-])
,
- (
), .
- ,
. , .
, ,
, .
,
.
:
1.
. , ,

. ,
, .
,
.
. ,
, , .
2.
.

3. .
4. return ,
. return
,
.
, .
.
:
int (*fun)(int x, int *y);
fun : int
int. int. ,
fun *, ,
int *fun (intx,int *y);
fun int.
fun
:
(*fun)(i,&j);
, fun
* .
.
,
. ,
.
:
double (*fun1)(int x, int y);
double fun2(int k, int l);
fun1=fun2;

/* */

(*fun1)(2,7);

/*

*/

fun1
, double, fun2.
, ..
, .

cos(x).

:
double proiz(double x, double dx, double (*f)(double x) );
double fun(double z);
int main()
{
double x;

/*

*/

double dx;

/*

*/

double z;

/*

*/

scanf("%f,%f",&x,&dx);

/*

x dx

*/

z=proiz(x,dx,fun);

/*

*/

printf("%f",z);

/*

*/

return 0;
}
double proiz(double x,double dx, double (*f)(double z) )
{

/*

*/

double xk,xk1,pr;
xk=fun(x);
xk1=fun(x+dx);
pr=(xk1/xk-1e0)*xk/dx;
return pr;
}
double fun( double z)
{

/*

*/

return (cos(z));
}

-
fun proiz .
, cos(x) proiz

z=proiz(x,dx,cos);
sin(x)

z=proiz(x,dx,sin);
, ..
. .
auto register
,
, .
, static,

.
- n! :
n! = 1 n=0;
n*(n-1)!

n>1 .

, , :
long fakt(int n)
{
return ( (n==1) ? 1 : n*fakt(n-1)

);

,

.
1.5.2.

.

.
, , .
, , ,
.

, .

, - (printf,scanf
..). .
.

() va_start, va_arg, va_end,


stdarg.h. , ,
, ,
.
.
va_start, va_arg, va_end
.
va_start arg_ptr
:
void va_start(arg_ptr,prav_param);
prav_param
, arg_prt
va_list :
va_list arg_ptr;
va_start va_arg.
va_arg

type_arg va_arg(arg_ptr,type);
type , arg_ptr,
arg_ptr ( type)
arg_ptr
. va_arg ,
.
va_end
(NULL).

.
-1.
,
.
:
#include
int main()
{ int n;
int sred_znach(int,...);
n=sred_znach(2,3,4,-1);

/* */
printf("n=%d",n);
n=sred_znach(5,6,7,8,9,-1);
/*

*/

printf("n=%d",n);
return (0);
}

int sred_znach(int x,...);


{
int i=0,

j=0,

sum=0;

va_list uk_arg;
va_start(uk_arg,x);

if (x!=-1) sum=x;

/*

uk_arg

*/

/*

*/

/*

*/

else return (0);


j++;
while ( (i=va_arg(uk_arg,int))!=-1)
/*
{

*/

/* */
sum+=i;

/*

*/

j++;
}
va_end(uk_arg);

/*

*/

return (sum/j);
}

1.5.3. main
main, -,
, , ,
. , ,
.
main ,
, . (

) argc argv. argc int,



, (
). argv ,
.
, .
main , argp,
main ()
-.
main :
int main (int argc, char *argv[], char *argp[])
, , - :
A:\>cprog working 'C program' 1
argc, argv, argp .1.
argc

[ 4

argv

]--> [

]-->

[A:\cprog.exe\0]

]-->

[working\0]

]-->

[C program\0]

]-->

[1\0]

[NULL]
argp

]--> [

]-->

[path=A:\;C:\\0]

]-->

[lib=D:\LIB\0]

]-->

[include=D:\INCLUDE\0]

]-->

[conspec=C:\COMMAND.COM\]

[NULL]
.1.

argc, argv, argp,



main.
,
main
.
:

int main ( int argc, char *argv[], char *argp[])


{

int i=0;
printf ("\n %s", argv[0]);
for

(i=1; i>=argc; i++)

printf ("\n %d %s", argv[i]);


printf ("\n
while

:");

(*argp)
printf ("\n %s",*argp);
argp++;

}
return (0);
}


geteuv, :
char *geteuv (const char *varname);
,
geteuv. ,
NULL.
, geteuv,
, .
puteuv.
- ,
, , ,
, main,
. _setargv _seteuv,
main.
-
,
_setargv _seteuv - main
, ().
:
_setargv()
{
}

return ;

/* */

-seteuv()
{

return ;

/* */

}
int main()
{

/* */

...
...
renurn (0);
}

_setargv _seteuv

. exe-.