第一次实验报告

C程序设计实验报告

姓名:樊铮雄 实验时间:2021.3.24 实验地点:一教522教室

实验目的与要求:
1、掌握DEVC++的安装方法,并实现程序的编辑、编译、连接、运行。
2、通过运行简单的C语言程序,初步了解C语言的结构特点。
3、掌握C语言的基本类型及使用方法。
4、熟悉C语言运算符和表达式的正确使用方法。
5、熟练掌握Markdown的用法

实验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("3+5=%d\n",c);
	printf("3*5=%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
main()
{
	float r,h,s,v;
	printf("Please input r,h:");
	scanf("%f %f",&r,&h);
	s=r*r*p;
	v=r*r*p*h/3;
	printf("s=%.2f v=%.2f",s,v);
}

运行图

流程图

实验小结:

1.对于代码不熟悉经常会忘记代码的效果
2.%0.2lf是指保留两位小数的浮点型输出;%6.2lf则是指总体字节位数为6包括小数点在内
3.写程序时总是不够细心容易落下一些细节,导致经常报错
posted @ 2021-03-29 22:37  难寻丫  阅读(51)  评论(0编辑  收藏  举报