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

C

2.

2.



( .) :
prog.c

/*

*/

#include

#include <stdio.h>

main,

int main()

int a, b, c;

printf(Enter 2 int values: );

scanf(%d %d, &a,&b);

c = a + b;

printf(%d+%d=%d\n,a,b,c);

return 0;
}

2.




#include
:
-
-
/






<limits.h>
<float.h>
<stdio.h>
<stdlib.h>
<math.h>
<ctype.h>
<string.h>
<time.h>
<stdarg.h>
<locale.h>

<conio.h>

2.

()

/ :
int

getchar( void ); - ;

int

putchar( int ch ); - ch ;

: int,

/ .

EOF - ,
/.

EOF

stdio.h.

2.

()

...printf -
.

,
.

- ,
:

, ;
( %).

[][][.][F|N|h|l]_

, ,
().
, .

2.

()

, ...printf

______________________________________________________________________________



______________________________________________________________________________
d

a, b, c, d, e, f
X

, x, A, B, C, D, E, F

f
e
g

E
G

[ - ] ...dd.dddddd
[ - ] d.dddddd e [ +/- ] ddd
e f
;

, e, E
, g, E

c
s


, '/0'

%
n

( )
int

2.

()

______________________________________________________________________________


______________________________________________________________________________
n
n ,
n , ;

0n

n ,
,

n;

...printf,

______________________________________________________________________________

______________________________________________________________________________


______________________________________________________________________________

- :
1 - d, i, o, u, x, X,
6 - e, E, f
- g, G,
'\0' - s
.0
- e, E, f -
.n
- d, i, o, u, x, X - n ;
n ,

n ;
n ,
-

- e, E, f - n ;

- g, G - n
- s
- n
______________________________________________________________________________

2.

()

...printf
______________________________________________________________________________


______________________________________________________________________________

-
;

- ,

- d, i, e, g, E, G :
(

+)

-)

- "" :
c, s, d, i, u

- 0

x, X

- 0x 0X

e, E, f

g, G

- e E

______________________________________________________________________________
. .
(

+ ) , "", .

2.

()

...scanf - .

, .

- , :

""

""

, ;

ASCII "" %;

%.

"" .

"" , ...scanf
""
"".

"" , ...scanf
,

- .

10

2.

()

%[*][][F|N][h|l|L]_

, (
, !), ()

- ( );

- , ,
"" .

- - far- (F) near-


(N), "" , ;

- - short (h) long (l) ,


"" ;

F|N

h|l
L

- - long double.

11

2.

()

...scanf

______________________________________________________________________________


-
______________________________________________________________________________
d

int *arg
o


i
10-, 8- 16-

u
10-
unsigned int *arg
x X
16-
int *arg
fe g E G

float *arg
s

char arg[ ]
c

char *arg char arg[W+1],


W
%


n
( )
int *arg, arg
%n
p
16- YYYY:XXXX
far *arg near *arg,
,
XXXX
.
______________________________________________________________________________
, ,
%[0-9A-F+-]s.
...scanf ,
. .
,

%[^abcd]s
.

12

2.

()

...scanf :

1. "
.

2. EOF.

3. .

...scanf (
) EOF ( sscanf ).

. ...scanf - ,
, ,
.
, - .

. 23-feb-89 - ,
.

"" .

scanf(" %d-%s-%d", &day, &month, &year);

13

2.

()

1. ( )

double fabs( double x );

double ceil( double x );


double floor( double x );
double fmod( double x, double y );

- double >=x;
- double <=x.
- x y.

3.

long labs( long x );

2. ,

int abs( int x );

double
double
double
double
double
double

sqrt( double x);


pow( double x, double y );
pow10( int x );
exp( double x );
log( double x );
log10( double x );

x.
x y.
10 x.
( e x ).
x.
x.

4.

double sin( double x );


double cos( double x );
double tan( double x );

double
double
double
double

asin( double x );
acos( double x );
atan( double x );
atan2( double y, double x );

atan2( y,x ) == atan(y/x).

14

2.

()


int rand(void); - pow(2,32) ,
0 RAND_MAX.
void srand(unsigned seed);

- .

void exit(int status);

- ,

,
;

status ( 0
, - - ).

int system(const char *command); -


command, .

15

2.

()

6. ASCII

int tolower( int c ); - c .


int toupper( int c ); - c .
int toascii( int c ); - c ASCII, , 7 .

int

is...( int

ch );

0 () != 0 ().

- :

isalpha
islower
isdigit
isascii
isgraph
isspace

('A'-'Z', 'a'-'z')
('a'-'z')
('0'-'9')
(0x00 - 0x7F)
(0x21 - 0x7E)
(0x09 - 0x0D, 0x20 )

isupper isalnum isxdigitisprint iscntrl ispunct -

('A'-'Z')
('A'-'Z', 'a'-'z', '0'-'9')
('0'-'9', 'A'-'F', 'a'-'f')
( 0x20 - 0x7E )
( 0x7F 0x00 - 0x1F )
( iscntrl isspace)

16