陈登辉 班级:电子信息工程一班 10
任务一:创建一个基本程序
实验内容:编写一个“显示华氏度和氏度对照表”的C程序。
实验目的:掌握C语言开发工具,掌握简单C程序的编辑、编译、连接和运行的一般过程。
程序:
//**************************************
//对fahr=0,20,...,300
//code by 陈登辉 120705110 2013-03-11
//**************************************
#include<stdio.h>
int main()
{
int fahr,celsius;
int lower,upper,step;
lower=0; /*温度表的下限*/
upper=300; /*温度表的上限*/
step=20; /*步长*/
fahr=lower;
printf("陈登辉 120705110\n", "");
while(fahr<=upper){
celsius=5*(fahr-32)/9;
printf("%d%d\n",fahr,celsius);
fahr=fahr+step;
}
return 0;
}
运行程序:
修改代码,将printf("%d %d\n", fahr,celsius);改为printf("%d\t %d\n", fahr,celsius);
运行程序:
任务2:进一步熟悉C语言编写的一般程序
实验内容:运行作业“例6-3”程序
实验目的:加深理解C程序的编辑、编译、连接和运行的一般过程
程序:
//************************************************
//code by 陈登辉 120705110 2013-03-16
//************************************************
/*源程序:exp6_3.cpp*/
#include<stdio.h>
void main()
{
void swap(int x,int y);
int a,b;
a=2,b=6;
printf("调用前:a=%d,b=%d\n",a,b);
swap(a,b);
printf("调用后:a=%d,b=%d\n",a,b);
}
void swap(int x,int y)
{
int temp;
printf("交换前:x=%d,b=%d\n",x,y);
temp=x;
x=y;
y=temp;
printf("交换后:x=%d,y=%d\n",x,y);
}
运行程序:
第一次上机心得:
这是我第一次写代码,在看到它运行成功的时候,感觉挺有成就感的,很爽 但过程中总是会出现些许错误;像是某个拼音打错 ,全角 半角忘记切换,等等;看似很小却又致命的错误,让人很是揪心,不过我相信错误是可以尽量减少的;总之前途是光明的,道路是崎岖的,漫漫的编程路还需要我在不断的学习和探索中前进。