第一次c程序设计上机报告

 

第一次c程序设计上机报告

姓名:颉益敏 学号:120705211 班级:12电子信息2

任务一:创建一个基本程序。

实验内容:编写一个“华氏温度与摄氏温度的对照表”c程序

实验目的:掌握c语言开发工具,掌握简单c程序的编写,翻译连接和运行的一般过程

我的程序:

 

 

//**********************
//对fahr=0,20...,3oo
//对应华氏温度与摄氏温度对照表
//code buy 颉益敏 120705211 2013-03-08
//***********************

#include<stdio.h>
int main()
{
 int fahr,celsius;
    int lower,upper,step;


    lower=0;    /*温度表的下线*/
 upper=300;  /*温度表的上线*/
    step =20;   /*步长*/
 fahr=lower;


    printf("颉益敏,120705211\n","");
 while(fahr<=upper){
  celsius=5*(fahr-32)/9;
        printf("%d%d\n", fahr,celsius);
  fahr=fahr+step;
 }
 return 0;
}


 

 

生成后:

1>------ 已启动生成: 项目: ConsoleApplication8, 配置: Debug Win32 ------
1>  源.cpp
1>  ConsoleApplication8.vcxproj -> d:\我的资料库\documents\visual studio 2012\Projects\ConsoleApplication8\Debug\ConsoleApplication8.exe
========== 生成: 成功 1 个,失败 0 个,最新 0 个,跳过 0 个 ==========

 

程序运行后的截图:

 

修改代码:将printf("%d%d\n,fahr,celsius");改为printf("%d\t%d\n,fahr,celsius")

 

//**********************
//对fahr=0,20...,3oo
//对应华氏温度与摄氏温度对照表
//code buy 颉益敏 120705211 2013-03-08
//***********************

#include<stdio.h>
int main()
{
 int fahr,celsius;
    int lower,upper,step;


    lower=0;    /*温度表的下线*/
 upper=300;  /*温度表的上线*/
    step =20;   /*步长*/
 fahr=lower;


    printf("颉益敏,120705211\n","");
 while(fahr<=upper){
  celsius=5*(fahr-32)/9;
        printf("%d\t %d\n", fahr,celsius);
  fahr=fahr+step;
 }
 return 0;
}

 

修改后运行效果截图:

 

 

任务二:进一步熟悉c程序编写的一般过程。

实验内容:运行作业“例6-3”程序

实验目的:加深理解c程序的编写,翻译,连接和运行的一般过程

 

/*源程序: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,y=%d\n",x,y);
 temp=x;
 x=y;
 y=temp;
 printf("交换后:x=%d,y=%d\n",x,y);
}

 

生成后:

 

1>------ 已启动生成: 项目: ConsoleApplication9, 配置: Debug Win32 ------
1>  源.cpp
1>  ConsoleApplication9.vcxproj -> d:\我的资料库\documents\visual studio 2012\Projects\ConsoleApplication9\Debug\ConsoleApplication9.exe
========== 生成: 成功 1 个,失败 0 个,最新 0 个,跳过 0 个 ==========

运行后的截图:

 

 

 

 

第一次c程序上机总结:

1:每个程序中都有#include<stdio.h>

2:main是主函数。

3:每个程序必须有一个main 函数

心得:

1:c 程序编写中不能因标点符号小:而忽略,每个符号都会影响整个程序的生成。

2:程序写起来不容易发表成功更。。。

3:一不小心截图就发表不上去只会留下代码。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值