第一次C程序设计上机报告
姓名:李乔峰学号:120705238班级:12级电信2班
任务一:创建一个基本程序。
实验内容:编写一个“显示华氏温度与摄氏温度对照表”C程序
实验目的:掌握C语言开发工具,掌握简单C程序的编辑、翻译、连接和运行的一般过程
我的程序
//************************
//对fahr=0,20,30...300
//打印华氏摄氏度和摄氏摄氏度的对照表
//code by 李乔峰,38,2013.3.8
//****************************
#include<stdio.h>
int main()
{
int fahr,celsius;
int lower,upper,step;
lower =0;
upper =300;
step =20;
fahr =lower;
printf("李乔峰,38\n");
while(fahr<=upper)
{celsius=5*(fahr-32)/9;
printf("%d%d\n",fahr,celsius);
fahr=fahr+step;
}
return 0;
}
运行效果
······························任务分割线······································
任务二:
我的程序
int _tmain(int argc, _TCHAR* argv[]);
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,y=%d/n",x,y);
temp=x;
x=y;
y=temp;
printf("交换后:x=%d,y=%d/n",x,y);
}
运行结果
······························任务分割线······································
小结
这是大学的第一次编程,虽然以前接触过类似编程,但这是第一次系统学C语言。
打代码是最容易忘的还是分号,还有括号容易少半个
不过还是顺利完成了任务