欢迎来到祥子的博客

你感觉我,就像我感觉你,世界上的另一个我。

《C语言程序设计》实验报告(一)

C程序设计实验报告

实验项目:课堂练习1-3-2,1-3-3,1-3-4,2-3-1,2-3-2

姓名:余永祥       实验地点:家          实验时间:2020年2月25日

一、实验目的与要求

1.了解C语言程序设计的基础

2.进行一些简单程序的编写任务

二、实验内容

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",c);
    printf("d=%d",d);
}

出现问题:无

解决方法:无

2、实验练习:

实验1-3-3:

 

 

 

#include<stdio.h>
main()
{
    printf("*\n");
    printf("**\n");
    printf("***\n");
    printf("****\n");
    printf("*****\n");
}

出现问题:无

解决方法:无

3、实验练习:

实验1-3-4:

 

 

 

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

出现问题:名词拼写出错

解决方法:多加熟悉

4、实验练习:

实验2-3-1:

 

 

 

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

出现问题:1.sqrt函数的运用较生疏,且不清楚要添加新的头函数<math.h>

                    2.对数字的类型输入还有问题

解决方法:向同学询问后清楚了相应的用法,以及了解头函数的意义

5、实验练习:

实验2-3-2:

 

 

#include<stdio.h>
main()
{
    double r,h,S,V;
    printf("Please input r,h:");
    scanf("%lf %lf",&r,&h);
    S=r*r*3.14;
    V=r*r*3.14*h/3;
    printf("底面积=%.2f",S); 
    printf("体积=%.2f",V);
}

出现问题:对数字的类型不理解

解决方法:对课件再次学习,理解int,double,foalt的意义

三、实验小结(在本次实验中收获与不足)

收获:对一些基础的程序有了理解,熟悉了一些C语言的用法

不足:需要熟悉一些关键字的不同用法,需要熟悉数字的类型,减少错误

posted @ 2020-02-28 21:58  赤羽业sama  阅读(657)  评论(1编辑  收藏  举报