PDF Archive

Easily share your PDF documents with your contacts, on the Web and Social Networks.

Share a file Manage my documents Convert Recover PDF Search Help Contact



C程序设计语言(K&R) 第2版 .pdf



Original filename: C程序设计语言(K&R) 第2版.pdf

This PDF 1.4 document has been generated by / PDF-XChange 3.30.0063 (Windows XP), and has been sent on pdf-archive.com on 23/08/2017 at 13:35, from IP address 61.244.x.x. The current document download page has been viewed 354 times.
File size: 1 MB (232 pages).
Privacy: public file




Download original PDF file









Document preview


PD

H
F-XC A N GE

w

.d o

o

m

w
w

c u-tr a c k

.c

1
C

C

C

C

C

1.1.

hello, world

C

“hello, world

#include <stdio.h>
main()
{
printf("hello, world\n");
}
UNIX

“.c

hello.c

cc hello.c

a.out
a.out
a.out
hello, world

#include <stdio.h>
main()
{
printf("hello, world\n");
}

main
main
main

printf
\n

C

C
C

Fortran

Pascal
main
main

——
main

main

main

#include <stdio.h>
C
7

B

main
()
{}

main

printf("hello, world\n");
"hello,
world\n"

printf

printf

"hello, world\n"
printf
C

\n
\n

printf

\n

\n

printf("hello, world
");
C
printf

#include <stdio.h>
main()
{
printf("hello, ");
printf("world");
printf("\n");
}

\n

\n
C

\b

\"

\\

\t
2.3

“hello, world

1-1

1-2

printf

\c

c

1.2.
=(5/9)( -32)
1
20
40
60
80
100
120
140
160
180
200
220
240
260
280
300

-17
-6
4
15
26
37
48
60
71
82
93
104
115
126
137
148
main

“hello, world

m

#include <stdio.h>
fahr=0 20 …

/*

300
*/

main()
{
int fahr, celsius;
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;

/*
/*
/*

*/
*/
*/

fahr = lower;
while (fahr <= upper) {
celsius = 5 * (fahr-32) / 9;
printf("%d\t%d\n", fahr, celsius);
fahr = fahr + step;
}
}

fahr=0 20 …

/*

300
*/
/* */

C

int fahr, celsius;
int lower, upper, step;
int
int float
-32768 32767
6

16
32
int
char
short
long
double

float

float

32
int
-38
38
10
10

C
——

4

int
float

lower = 0;
upper = 300;
step = 20;
fahr = lower;

while

while (fahr <= upper) {
...
}
while
(fahr<=upper)

3
(fahr>upper)
while

while

while (i < j)
i = 2 * i;
while
C

celsius = 5 * (fahr - 32) / 9
celsius
5

9

C

5 / 9

5
0

5 / 9
printf

9
0

printf

7

%
……
%d
printf(" %d\t%d\n", fahr, celsius);
fahr
printf

celsius

\t
%

……

C

printf

C
C

printf
ANSI

printf

C
7.4

7
7
scanf

scanf

printf

printf
%d
printf(" %3d %6d\n", fahr, celsius);
fahr

0
20
40
60
80
100
...

celsius

fahr

3

6

celsius

-17
-6
4
15
26
37

0

-17.8

-17

#include <stdio.h>
/* print Fahrenheit-Celsius table
for fahr = 0, 20, ..., 300; floating-point version */
main()
{
float fahr, celsius;
float lower, upper, step;
lower = 0;
upper = 300;
step = 20;

/* lower limit of temperatuire scale */
/* upper limit */
/* step size */

fahr = lower;
while (fahr <= upper) {
celsius = (5.0/9.0) * (fahr-32.0);
printf("%3.0f %6.1f\n", fahr, celsius);
fahr = fahr + step;
}
}
fahr

celsius

float
5 / 9

0
5.0 / 9.0

fahr – 32

32

2
fahr = lower;

while (fahr <= upper)
int

printf

%3.0f
%6.1f

float

fahr
celsius

3
6

1
0
20
40
...

-17.8
-6.7
4.4
%6f

6

%.2f

%f

%d
%6d
%f
%6f
%.2f
%6.2f

6
6
6
printf
%s

1-3
1-4

1.3.

for

#include <stdio.h>

%o
%%

%

%x

%c

/*

main()
{
int fahr;

*/

for (fahr = 0; fahr <= 300; fahr = fahr + 20)
printf("%3d %6.1f\n", fahr, (5.0/9.0)*(fahr-32));
}

int

fahr

for
printf

C
printf
%6.1f
for
while

while

for

for

3

fahr = 0

fahr <= 300
true
printf
fahr = fahr + 20
fahr

faise
while

for

whi1e

for

for
while
1-5

300

0

1.4.
300 20
#define

#define
#define

#include <stdio.h>
#define LOWER 0
#define UPPER 300
#define STEP 20

/* lower limit of table */
/* upper limit */
/* step size */

/* print Fahrenheit-Celsius table */
main()
{
int fahr;
for (fahr = LOWER; fahr <= UPPER; fahr = fahr + STEP)
printf("%3d %6.1f\n", fahr, (5.0/9.0)*(fahr-32));
}
LOWER UPPER

STEP

#define

1.5.

0
C
getchar

putchar

getchar

c = getchar()
c
7
putchar
putchar()
c

putchar

printf


Related documents


PDF Document untitleddocument 1
PDF Document c programming complete jntu programs
PDF Document data types and sizes 2 image marked
PDF Document variable names 2 image marked
PDF Document exercices
PDF Document wtf 1


Related keywords