C Primer Plus_第二章_C语言概述_复习题与编程练习

REVIEW

1.如何称呼C程序的基本模块?
ans
它们被称为函数

2.什么是语法错误?给出一个英语例子和一个C语言例子
me
C的语法错误是指把正确的C符号放在了错误的位置
likes coding He. 
int main(void)
()
ans
语法错误就是指违背了如何把语句或程序放置在一起的规则。
Me speaks English good.
printf "where are the parentheses?";

3.什么是语义错误?给出一个英语例子和一个C语言例子
ans
语义错误就是指含义上的错误(编译不出语法错误)。
My favorite singer is GuoDegang.
thrice_n = 3 + n;

4.评定下面的程序
# include <</font>studio.h>
int main(void)  
( {
int s ;

s: = 56; s= 56;
print f ( " There are s %d weeks in a year. ",s );
return 0;
) }



PRACTICE
1.利用printf函数输出姓名
#include
int main(void)
{
printf("Tom Smith\n");
printf("Tom\nSmith\n");
printf("Tom ");
printf("Smith\n");
 
return 0;
}
 
2.输出您的姓名和地址

#include
int main(void)
{
 printf("Name: Tom Smith\n");
 printf("Add: China AnHui MaAnShan\n");
 return 0;
}
 
3.把年龄转换成天数并显示二者的值

#include
int main(void)
{
 int age;
 int day;
 age = 24;
 printf("tom is %d years old\n",age);
 printf("tom has been on earth for %d days\n",age*365);
 return 0;
}
 
4.

#include
void prnt1(void);
void prnt2(void);
int main(void)   //主函数定义用 int main(void)
{
 prnt1();
 prnt1();
 prnt1();
 prnt2();
 return 0;
}
void prnt1(void)  //子函数定义用 void func(void)
{
 printf("For Tom is a jolly good fellow!\n");
}
void prnt2(void)
{
 printf("Which nobody can deny!!!\n");
}
 
5.

#include
int main(void)
{
 int toes,t_sqr,t_sum;
 toes = 10;
 t_sqr = toes * toes;
 t_sum = toes + toes;
 printf("toes = %d\ntoes and = %d\ntoes square = %d\n",toes,t_sum,t_sqr);
 
 return 0;
}
 
6.

#include
void prt_s(void);
void prt_n(void);
int main(void)
{
 prt_s();
 prt_s();
 prt_s();
 prt_n();
 prt_s();
 prt_s();
 prt_n();
 prt_s();
 prt_n();
 return 0;
}
void prt_s(void)
{
 printf("Smile!");
}
void prt_n(void)
{
 printf("\n");
}
 
7.

#include
void one_three(void);
void two(void);
int main(void)
{
 printf("starting now:\n");
 one_three();
 printf("done!\n");
 return 0;
}
void one_three()
{
 printf("one\n");
 two();
 printf("three\n");
}
void two()
{
 printf("two\n");
}

转载于:https://www.cnblogs.com/TomLily/p/5814589.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值