姓名:陈裕坤 学号:120705213 班级:12电信2班
任务一:创建一个基本程序。
实验内容:编写一个“显示华氏温度与摄氏温度对照表”C程序
实验目的:掌握C语言开发工具,掌握简单C程序的编辑、编译、连接和运行的一般过程
我的程序:
//***************************************
//对 fahr=0,20,…,300
//Cody by 陈裕坤 120705213 2013,3,8
//***************************************
#include<stdio.h>
int main()
{
int fahr,celsius;
int lower,upper,step;
lower=0;
upper=300;
step=20;
fahr=lower;
printf("陈裕坤,120705213\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程序的编辑、编译、连接和运行一般过程
我的程序:
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
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,y=%d\n",x,y);
temp=x;
x=y;
y=temp;
printf("交换后:x=%d,y=%d\n",x,y);
}
第一次运行成功,效果如图:
……………………………………任务分割线……………………………………
第一次C程序上机心得体会:
知道程序使用步骤之后就得心应手了,输入代码过程也很顺利,感觉还可以