C 语言实验报告 实验1-1: hello world 程序: 源代码: #include main() { printf("hello world!\n"); system("pause"); } 实验1-2: 完成3 个数据的输入、求和并输出计算结果的程序: 源代码: #include main() { int i,j,k,sum; scanf("%d%d%d",&i,&j,&k); sum=i+j+k; printf("sum=%d",sum); system("pause"); 实验1-3: 在屏幕上输出如下图形: A BBB CCCCC 源代码: #include main() { printf(" A\n"); printf(" BBB\n"); printf(" CCCCC\n"); system("pause"); } 实验2-1: 计算由键盘输入的任何两个双精度数据的平均值 源代码: #include main() { double a,b; scanf("%lf%lf",&a,&b); printf("%.1lf\n",(a+b)/2); system("pause"); } 实验2 -2 : 写一个输入7 个数据的程序,把输入的数据代入a + b * (c – d ) / e * f – g 表达式进行运算 源代码: #include main() { float a,b,c,d,e,f,g,x; scanf("%f%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f,&g); x=a + b * (c - d ) / e * f - g; printf("x=%f",x); system("pause"); } 实验2 -3 : 编写一个C 语言程序,测试下列各表达式: i, j i + 1 , j + 1 i++ , j++ ++i , ++j i+++++j 源代码: #include main() { int i=1,j=1; printf("%d %d\n",i+1,j+1); printf("%d %d\n",i++,j++); printf("%d %d\n",++i,++j); printf("%d\n",(i++)+(++j)); system("pause"); } 实验2 -4 : 输入存款金额money,存期year 和年利率rate,根据下列公式计算存款到期时的利息interest(税前),输出时保留2 位小数。 interest = money(1+rate)year - money 源代码: #include #include main() { int year=2; float rate=0.1,money=1000; float futureMoney; futureMoney=money*pow((1+rate),year); printf("%10.2f",futureMoney); system("pause"); } 实验2 -5 : 输入华氏温度,输出对应的摄氏温度。计算公式如下: c = 5 * ( f - 32) / 9 其中,c 表示摄氏温度,f 表示华氏温度 源代码: #include main() { int c,f; scanf("%d",&f); c = 5 * ( f - 32) / 9; printf("%d",c); system("pause"); } 实验3 -1 : 编...