求助, C语言试题

来源:百度知道 编辑:UC知道 时间:2024/06/27 03:55:38
有几条题目不会
请那位大哥可以帮帮忙,小弟不胜感激.定当重赏
简答题
1. 与字面常量相比,使用符号常量有哪些优点?
2. 比较continue语句和break语句的异同。
3. 以下程序段的功能是将给定的嵌套if-else语句改写成对应的switch语句,使其完成相同的功能。请填空。
if-else语句:
if (score >=90 && score < 100)
printf(“Excellent”);
else if (score >= 80)
printf(“Good”);
else if (score >= 70)
printf(“Normal”);
else if (score >= 60)
printf(“Pass”);
else
printf(“Bad”);
switch语句:
switch ()
{
()printf(“Excellent”); break;
case 8: printf(“Good”); break;
case 7: printf(“Normal”); break;
case 6: printf(“Pass”); break;
()printf(“Bad”); break;
}
4. 写出下列程序的运行结果。
#include <stdio.h>
main()
{
int a, b;
a = 20;
b = 8;
printf(“%d+%d=%d\n”, a, b, a+b);
printf(“%d-%d=%d\n”, a, b, a-b);
printf(“%d*%d=%d\n”, a, b, a*b);
printf(“%d/%d=%d\n”, a, b, a/b);
printf(“%d%%%d=%d\n”, a,

简答题
1. 与字面常量相比,使用符号常量有哪些优点?
答:符号常量使用更加直观。增强程序可读性。

2. 比较continue语句和break语句的异同。
答:continue结束本次循环;break跳出循环。

3. 以下程序段的功能是将给定的嵌套if-else语句改写成对应的switch语句,使其完成相同的功能。请填空。
if-else语句:
if (score >=90 && score < 100)
printf(“Excellent”);
else if (score >= 80)
printf(“Good”);
else if (score >= 70)
printf(“Normal”);
else if (score >= 60)
printf(“Pass”);
else
printf(“Bad”);
switch语句:
switch (score/10)
{
(case 9:)printf(“Excellent”); break;
case 8: printf(“Good”); break;
case 7: printf(“Normal”); break;
case 6: printf(“Pass”); break;
(default:)printf(“Bad”); break;
}

4. 写出下列程序的运行结果。
#include <stdio.h>
main()
{
int a, b;
a = 20;
b = 8;
printf(“%d+%d=%d\n”, a, b, a+b);
printf(“%d-%d=%d\n”, a, b, a-b);
printf(“%d*%d=%d\n”, a, b, a*b);
printf