1、一、实验目的1. 熟悉 C 语言中基本数据类型的概念。2. 掌握各种常量的正确表示方法。3. 掌握变量的定义、赋值和初始化的方法。4. 掌握算术运算符、赋值运算符、增量运算符、逗号运算符的使用方法。5. 掌握数据类型转换的概念。二、实验内容1. 将下列数学表达式写成 C 表达式,并编写程序验证其正确性。(1) (2)yx23acb24(3) (4)ba1 33zyx2. 已有如下变量定义,求下列表达式的值。编写程序验证其正确性。(1 ) double x=1.2,y=8.5;int a=3;x+a%3*(int)(x+y);(2) int a=2,b=3;double x=3.5,y=2.5;
2、(double)(a+b)/2+(int)x%(int)y;(3) int x=4,y=8;(+x)*(-y);(4) int e=1,f=4,g=2;double m=10.5,n=4.0,k;k=(e+f)/g+sqrt(n)*1.2/g+m;(5) double x=2.5,y=4.7;int a=7;x+a%3*(int)(x+y)%2/4;(6) int a,b;int x;x=(a=2,b=5,a+,b+,a+b);1(1)#include#includevoid main()int x=1,y=2;double z;z=(2*x*x+3*y*y)/(x+y);cout#inclu
3、devoid main()int a=1,b=5,c=2;double r,t;r=(-b+sqrt(b*b-4*a*c)/2*a;t=(-b-sqrt(b*b-4*a*c)/2*a;cout#includevoid main()int a,b,c;double z;coutabc;z=1+(1+a/b)/(1-a/c);cout#includevoid main()int x=1,y=2,z=3;double r;r=x/(sqrt(fabs(x*x*x+y*y*y+z*z*z);cout#includevoid main()int a=3;double x=1.2,y=8.5,q;q=x+
4、a%3*(int)(x+y);cout#includevoid main()int a=2,b=3;double x=3.5,y=2.5,r;r=(double)(a+b)/2+(int)x%(int)y;cout#includevoid main()int x=4,y=8,t;t=(+x)*(-y);cout#includevoid main()int e=1,f=4,g=2;double m=10.5,n=4.0,k;k=(e+f)/g+sqrt(n)*1.2/g+m;cout#includevoid main()double x=2.5,y=4.7,e;int a=7;e=x+a%3*(int)(x+y)%2/4;cout#includevoid main()int a,b,x;x=(a=2,b=5,a+,b+,a+b);cout“a=“a“t“b=“b“t“a+=“a+“t“b+=“b+“t“a+b=“a+b“t“x=“xendl;