1
 C  C 
 C 
C 
 C 
1.1. 
hello, world
 C “hello, world
#include 
main()
{
   printf("hello, world\n");
}
 UNIX 
“.c hello.c
cc hello.c
 a.out
a.out
 a.out
hello, world
#include 
main()
{
   printf("hello, world\n");
}
 main 
main 
main  printf 
\n 
 C 
 C 
C  Fortran  Pascal 
 main main 
—— main 
 main 
main 
#include 
 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 
main()
{
   printf("hello, ");
   printf("world");
   printf("\n");
}
\n \n 
C \t 
\b \"\\2.3 
 11
“hello, world
 12
 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
 */
#include 
/*  fahr=020… 300 
main()
{
  int fahr, celsius;
  int lower, upper, step;
  lower = 0;      /*  */
  upper = 300;    /*  */
  step = 20;      /*  */
  fahr = lower;
  while (fahr <= upper) {
      celsius = 5 * (fahr32) / 9;
      printf("%d\t%d\n", fahr, celsius);
      fahr = fahr + step;
  }
}
/* fahr=020… 300 
 */
/**/
 C 
    int fahr, celsius;
    int lower, upper, step;
 int float 
int  float  int 
 16 3276832767  32  int float 
 32  6  10381038 
 int  float C 
char
short
long
double
——
 4 
    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  5 / 9 C 
 5  9 
5 / 9  0 0
 printf printf 
 7 %
……
%d 
printf(" %d\t%d\n", fahr, celsius);
 fahr  celsius \t
printf %……
printf  C C 
printf  C 
ANSI  printf 
 C  7 
 7 
 7.4  scanf scanf  printf 
 printf 
%d 
printf(" %3d %6d\n", fahr, celsius);
 fahr  celsius fahr  3 celsius  6 
     0     17
    20      6
    40       4
    60      15
    80      26
   100      37
   ...
 017.817
   #include 
   /* print FahrenheitCelsius table
       for fahr = 0, 20, ..., 300; floatingpoint version */
   main()
   {
     float fahr, celsius;
     float lower, upper, step;
     lower = 0;      /* lower limit of temperatuire scale */
     upper = 300;    /* upper limit */
     step = 20;      /* step size */
     fahr = lower;
     while (fahr <= upper) {
         celsius = (5.0/9.0) * (fahr32.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  float 
printf %3.0f  fahr 3 
%6.1f celsius 6 
 1 
     0   17.8
    20    6.7
    40     4.4
   ...
%6f  6 %.2f
%f 
%d
%6d
%f
%6f
%.2f
%6.2f
printf %o %x %c
 6 
 6 
 6 
%s %%%
 13
 14
1.3. 
for 
   #include 
   /*—*/
   main()
   {
       int fahr;
       for (fahr = 0; fahr <= 300; fahr = fahr + 20)
           printf("%3d %6.1f\n", fahr, (5.0/9.0)*(fahr32));
   }
 int  fahr for 
 printf 
 C 
 printf 
%6.1f 
for  while  for 
while  for  3 
fahr = 0
fahr <= 300
true
 printf 
fahr = fahr + 20
 fahr faise
 while for 
 whi1e  for 
for 
 while 
 15
 300  0 
1.4. 
 30020 
#define