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

李秋萍 电子信息2班 120705201

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

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

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

我的程序

//***************************************      
//对 fahr=0,20,…,300      
//Cody by 李秋萍 120705201 2013,3,8      
//***************************************      
      
#include<stdio.h>      
      
      
int main()      
{      
    int fahr,celsius;      
    int lower,upper,step;      
      
    lower=0;      
    upper=300;      
    step=20;      
    fahr=lower;      
      
    printf("李秋萍,120705201\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程序上机体会:

由于博客没有及时弄好,作业晚交了好几天。

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值