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 ,