第一次实操C语言的心得体会
C程序设计实验报告
姓名:陈英卉 实验地点:一教522 实验时间:2021.3.24
一、实验目的与要求
1、掌握DEVC++的安装方法,并实现程序的编辑、编译、连接、运行。
2、通过运行简单的C语言程序,初步了解C语言的结构特点。
3、掌握C语言的基本类型及使用方法。
4、熟悉C语言运算符和表达式的正确使用方法。
5、熟练掌握Markdown的用法。
二、实验内容
1.实验练习:1.3.2
#include <stdio.h>
main()
{
int a,b,c,d;
printf("please enter a,b:");
scanf("%d,%d",&a,&b);
c=a+b;
d=a*b;
printf("c=%d\n",c);
printf("d=%d\n",d);
}
实验小结
刚开始运行的时候敲代码有点慢,中英字符标点会搞混淆
实验训练:1.3.3
#include <stdio.h>
main()
{
printf("*\n");
printf("**\n");
printf("***\n");
printf("****\n");
}
实验小结
这个训练打得比较轻松,但是速度不快,后期多练熟能生巧
实验训练:1.3.4
#include <stdio.h>
#define p 3.14
int main()
{
float r1,r2;
double s1,s2,s;
printf("please enter r1,r2:\n");
scanf("%f%f",&r1,&r2);
s2=r2*r2*p;
s1=r1*r1*p;
s=s2-s1;
printf("s=%lf\n",s);
return 0;
}
实验小结:刚刚开始时没有设置“p"这个变量,导致运行出错
实验训练:1.3.5
#include <stdio.h>
#define p 3.14
main()
{
float r,h,v,s;
printf("please input r,h:");
scanf("%f,%f",&r,&h);
s=r*r*p;
v=r*r*p*h/3;
printf("s=%.2f\n,v=%.2f\n",s,v);
}
实验小结:更加深刻的理解了“P”这类运算
#include <stdio.h>
#include <math.h>
main()
{
int a,b,c;
printf("please enter a,b:");
scanf("%f,%f",&a,&b);
c=(b+sqrt(b*b+2*a))/(a-b);
printf("c=%0.2f\n",c);
}
实验小结:一开始没有加“include <math.h>”这一行代码导致运行失败