当前位置:嗨网首页>书籍在线阅读

21-复习题

  
选择背景色: 黄橙 洋红 淡粉 水蓝 草绿 白色 选择字体: 宋体 黑体 微软雅黑 楷体 选择字体大小: 恢复默认

2.11 复习题

复习题的参考答案在附录A中。

1.C语言的基本模块是什么?

2.什么是语法错误?写出一个英语例子和C语言例子。

3.什么是语义错误?写出一个英语例子和C语言例子。

4.Indiana Sloth编写了下面的程序,并征求你的意见。请帮助他评定。

include studio.h
int main{void} /* 该程序打印一年有多少周 /*
(
     int s
     s := 56;
     printf(There are s weeks in a year.);
     return 0;

5.假设下面的4个例子都是完整程序中的一部分,它们都输出什么结果?

a. printf("Baa Baa Black Sheep.");
   printf("Have you any wool?\n");
b. printf("Begone!\nO creature of lard!\n");
c. printf("What?\nNo/nfish?\n");
d. int num;
   num = 2;
   printf("%d + %d = %d", num, num, num + num);

6 .在 mainintfunctionchar= 中,哪些是C语言的关键字?

7 .如何以下面的格式输出变量 wordslines 的值(这里, 3020350 代表两个变量的值)?

There were 3020 words and 350 lines.

8.考虑下面的程序:

#include <stdio.h>
int main(void)
{
      int a, b;
      a = 5;
      b = 2; /* 第7行 */
      b = a; /* 第8行 */
      a = b; /* 第9行 */
      printf("%d %d\n", b, a);
      return 0;
}

请问,在执行完第7、第8、第9行后,程序的状态分别是什么?

9.考虑下面的程序:

#include <stdio.h>
int main(void)
{
      int x, y;
      x = 10;
      y = 5;        /* 第7行 */
      y = x + y;    /*第8行*/
      x = x*y;      /*第9行*/
      printf("%d %d\n", x, y);
      return 0;
}

请问,在执行完第7、第8、第9行后,程序的状态分别是什么?