第一次实验报告

第一次实验报告

姓名:贺煜林 实验地点:一教522教室 实验时间:2021.3.29

实验目的

1.掌握DEVC++的安装方法,并实现程序的编辑、编译、连接、运行。

2.通过运行简单的C语言程序,初步了解C语言的结构特点。

3.掌握C语言的基本类型及使用方法。

4.熟悉C语言的运算符和表达式的正确使用方法。

实验1.3.2

#include<stdio.h>
#define p 3.14
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");
    printf("*****\n");

}

实验1.3.4

#include<stdio.h>
main()
{
    printf("Data Types and Sizes :\n");
    printf("long: %d\n",sizeof(long));
    printf("unsigned int: %d\n",sizeof(unsigned int));
    printf("double: %d\n",sizeof(double));
}


实验2.3.1

#include<stdio.h>
#include<math.h>
main()
{
	float a,b;
	double  x;
	printf("Please enter a,b:");
	scanf("%f,%f",&a,&b);
	x=(b+sqrt(b*b+2*a))/(a-b);
	printf("x=%.2lf",x);
}


实验2.3.2

#include <stdio.h>
#define p 3.14
int main()
{
    float r,h,s,v;
    printf("Please input r,h:");
    scanf("%f,%f",&r,&h);
    s=r*r*p;
    v=r*p*h/3;
    printf("s=%.2f\n",s);
    printf("v=%.2f\n",v);
    
}


遇到的问题

1:定义变量时中间忘记打空格,忘记输入scanf函数
2:1.3.2刚开始"d%,%d"中","没打出来,导致报错,其它的没什么问题。
3:1.3.4刚开始少了一个括号没发现,改过来了,加上对定义变量类型还不是那么熟悉,有一点困难
4:2.3.1不知道要输入math函数,然后%.2f的涵义

流程图

总结

由于是第一次实验,操作不是那么的熟练,还需要大量的练习,来更好的帮助自己加深印象和熟悉C语言。在这次的操作过程中,室友给了我很大的帮助,以后有不懂的,还得多问问。

posted @ 2021-03-29 22:51  HEYULIN  阅读(56)  评论(1编辑  收藏  举报