C语言程序设计教程第2版课件第4章
- 格式:ppt
- 大小:281.00 KB
- 文档页数:42


第1章 计算机语言及C语言概述
1.1 计算机语言和计算机程序
1.2 C语言概述
1.2.1 C语言的产生和发展
1.2.2 C语言的特点
1.2.3 C程序的结构
/*第一个C程序*/
#include
void main( )
{
printf("This is the first C program.\n");
}
/*本程序实现从终端输入两个整数并求和*/
#include
void main( )
{
int a,b,sum; /*变量定义语句*/
scanf("%d%d",&a,&b); /*从终端输入两个整数分别赋给变量a和b*/
sum=a+b; /*求a、b的和并赋给变量sum*/
printf("sum=%d\n",sum); /*将sum值输出*/
}
C语言程序设计教程
2
#include
/*求面积函数*/
float CircleArea(float r) /*CircleArea函数的首部*/
{ float s; /*定义浮点型变量s*/
s=3.14159*r*r; /*给s赋值为半径为r的圆的面积*/
return s; /*将s的值返回,带回至main函数中的被调用位置*/
}
/*主函数*/
void main( )
{ float r, Area; /*变量r用来存储半径值,Area用来存储面积值*/
printf("Input r:"); /*输出提示信息*/
scanf("%f",&r); /*输入一个实型数据赋给r,%f为浮点型数据格式控制符*/
Area=CircleArea(r); /*调用CircleArea函数,将返回值赋给Area*/
printf("r=%f, Area=%f\n",r,Area); /*输出半径及面积*/
promotion of employment, form a reasonable and orderly pattern of income distribution, build a more fair and sustainable social security systems, medical and health system reform. The plenary, innovation of social governance, must focus on the maintenance of fundamental interests of the overwhelming majority of the people, maximize factors, enhance social development, improving social governance, the interests of national security, ensure that the people live and work, social stability and order. o improve social governance, stimulating social organization, innovative and effective system of preventing and resolving social conflicts, improving the public security system, set up the National Security Council, national security systems and national security strategy to ensure national security. Plenary session, the construction of ecological civilization, you must establish systems of ecological system, using the system to protect the ecological environment. o improve naturalresources asset property right system and use control, red line of delimitation of ecological protection, resources paid use system and ecological compensation system in ecological environment protection management system reform. Plenary session, centering on building a listening party command, can win and having a fine style of the people's army, a strong army under the new situation of the party Goals, restricting the development of national defense and army building is solved outstanding contradictions and problems, innovation and development of military theory, enhance military strategic guidance, improve the military strategy in the new period, building a modern military force system with Chinese characteristics. o deepen the adjustment of personnel system reform in the army, military policy and system reform, promote the development of military and civilian integration depth. Plenary session stressed that comprehensive reform must be to strengthen and improve theparty's leadership, give full play to the core role of the party commands the overall situation and coordinating all parties, improving the party's leading water ... Margin. Challenged the leadership of the Communist Party of China, Marxism-Leninism and Mao Zedong thought by Deng Xiao-ping's flag, replaced by three representatives and the harmonic society. The former Communist Party spirit and social cohesion point of almost all political makeover. Characteristics of socialism public ownership is shifting to private ownership, planned regulation and market regulation, the proletarian regime controlled by the elite. Of universal equality, fairness and basic principles of distribution system is socialist society, however after economic monopolized by powerful, vested interests growemployers do not have the same status, hardly seems fair social distribution. State key protection of capital interests rather than the interests of citizens, had been hits the bottom of the proletariat
c语言程序设计教程第二版课后答案
【篇一:c语言程序设计(第2版)-- 课后题答案】
p> 参考答案
第1章 进入c语言程序世界
二、
1.i love china!
printf(we are students.\n)
2.6
项目实训题参考答案
1.编写一个c程序,输出以下信息:
* * * * * * * * * * * * * * * * * * * *
i am a student!
* * * * * * * * * * * * * * * * * * * *
main()
{ printf(********************\n);
printf( i am a student!\n);
printf(********************\n);
}
2.已知立方体的长、宽、高分别是10cm、20cm、15cm,编写程序,求立方体体积。 解:
main()
{
int a,b,c,v;
a=10;
b=20;
c=15;
v=a*b*c;
printf(v=%d,v);
}
本程序运行结果为:
v=3000
第2章 编制c程序的基础知识
一 选择题
c b a b a c c
二 操作题
,2,-8,2 3.000000,2.500000,-8.000000
2. abc de
fgh
why is21+35equal 52
3.
3
4
2
1
4. aa
a
项目实训题
1.定义一个符号常量m为5和一个变量n值为2,把它们的乘积输出。
#define m 5
main()
{ int n,c;
n=2; c=m*n;
printf(%d\n,c);}
2.编程求下面算术表达式的值。
(1)x+a%3*(int)(x+y)%2/4,设x=2.5,a=7,y=4.7;
习题2答案
1.答案:以下合法常量已做标注,非法常量未做标注
65535(合法) 3.5U 66L(合法) 1.24e-2(合法)
6e1.2 '@'(合法) 'abc' "abc"(合法)
"?"(合法) 892.(合法) .123(合法) -0xAB (合法)
2.答案:以下合法的已做标注,不合法的未做标注
Max(合法) _301(合法) 4_5 M-1
Char(合法) int my name M.D.Jhon
3.答案:
x: 00000000 00000000 00000000 00001100
y: 00000000 00000000 00000000 01001101
z: 11111111 11111111 11111111 10001100
4.答案:运行结果:3.5 结果表达式类型:double 型
5.答案:运行结果:2.5 结果表达式类型:double 型
6.答案:
表达式序号 a的值 n的值 表达式的值
(1) 16 5 16
(2) 6 5 6
(3) 40 5 40
(4) 0 5 0
(5) 0 1 0
(6) 0 5
0
(7) 15 5 60
(8) 3 18 18
(9) 3 3 18
(10) 1 5 1
7.答案:00010101
8.答案:11111111 11111111 11111111 11111001
9.答案:00000000 00000000 00000000 11111001
10.答案:
表达式序号 (1) (2) (3) (4) (5) (6) (7) (8)
表达式运算结果 0 1 1 0 1 1 0 1 11.答案:
结果a和b的值分别是8和5。题目中的三个连续运算a=a+b; b=a-b; a=a-b;,效果是交换变量a和b的值,因此a和b的初值无论是什么,结论还是a和b的值进行了交换。
12.答案: