实验一C程序的运行环境和运行C程序的方法

更新时间:2023-10-12 15:54:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

dstandardizationofsafetyproduction,andstrivetoachieve\nsicallysafe\ethpitsafetysectionandisaunitofsecurityofficersresponsibleforminesafetydutiesandsupervisetheimplementationofthefollow-upto,andimplementationofthesystem,prosecution.PartImanagementsystems...Youcanusebrazierswhen,2--3metersfromthegroundandputthefireoutbeforethework,confirmthenofirebeforetheycanleave;Highway11non-staffinthemarginwithin50m,radiusoftheexcavationwork,andworkingwithin6metresoftheedgeandstayundertheumbrellaheading;12,blastingintothepitpersonnelmustfollowtheshootingguard'scommand,hidetosafety;13non-miningvehicles(includingbicycles,animal-drawnvehicle,motorvehicles,etc)willbebannedfromenteringthepitsandotherproductionareaonpainofheavyfines,resultinginaccidentstobeinvestigatedforresponsibility;14shootingthefollowingmechanicalsafetydistancesasfollows:categorynamemechanicalcannonsshallowholesandpopshootingexposedblastingunits:metersdiggingmachinerigcargunpowderotherequipment-pitequipment,especiallyanelectricalswitchandavarietyofsafetydevices,inadditiontospecifyingtheuseofresponsiblepersonnel,bananytouchingofotherpersonnel;16foundthatpowerlinesorcablesbreakinggroundbeforewithoutascertainingwhetherthecharged,prohibitsanyonefromtouching,andshouldleave5metersaway,andimmediatelynotifythepersonchecking;17withouttheleadership'sconsent,arenotallowedtotakethestrippedtrucks,watertankers,oiltankers,asaresultofthecau 实验一 C程序的运行环境和运行C程序的方法

1.实验目的

(1)了解所用的计算机系统的基本操作方法,学会独立使用该系统 (2)了解在该系统上如何编辑、编译、连接和运行一个C程序 (3)通过运行简单的C程序,初步了解C源程序的特点 2.实验内容和步骤

(1)检查所用的计算机系统是否已安装了C编译系统并确定它所在的子目录,并阅读本次上机文件夹中的编译环境文件夹的图片文档。 (2)用鼠标双击桌面上“我的电脑”,进入资源管理器,双击D盘,进入D盘根目录,如图1所示。 图1

(3)将鼠标指向右边空白处,点鼠标右键,在弹出的菜单上选新建,在出现的级联菜单上选文件夹,如图1,则在D盘根目录下新建一文件夹,如图2,修改此文件夹的名字为自己的名字。

dstandardizationofsafetyproduction,andstrivetoachieve\nsicallysafe\safetysectionandisaunitofsecurityofficersresponsibleforminesafetydutiesandsupervisetheimplementationofthefollow-upto,andimplementationofthesystem,prosecution.PartImanagementsystems...Youcanusebrazierswhen,2--3metersfromthegroundandputthefireoutbeforethework,confirmthenofirebeforetheycanleave;Highway11non-staffinthemarginwithin50m,radiusoftheexcavationwork,andworkingwithin6metresoftheedgeandstayundertheumbrellaheading;12,blastingintothepitpersonnelmustfollowtheshootingguard'scommand,hidetosafety;13non-miningvehicles(includingbicycles,animal-drawnvehicle,motorvehicles,etc)willbebannedfromenteringthepitsandotherproductionareaonpainofheavyfines,resultinginaccidentstobeinvestigatedforresponsibility;14shootingthefollowingmechanicalsafetydistancesasfollows:categorynamemechanicalcannonsshallowholesandpopshootingexposedblastingunits:metersdiggingmachinerigcargunpowderotherequipment-pitequipment,especiallyanelectricalswitchandavarietyofsafetydevices,inadditiontospecifyingtheuseofresponsiblepersonnel,bananytouchingofotherpersonnel;16foundthatpowerlinesorcablesbreakinggroundbeforewithoutascertainingwhetherthecharged,prohibitsanyonefromtouching,andshouldleave5metersaway,andimmediatelynotifythepersonchecking;17withouttheleadership'sconsent,arenotallowedtotakethestrippedtrucks,watertankers,oiltankers,asaresultofthecau

图2

(4)进入所用的集成环境。 (5)熟悉集成环境的界面和有关菜单的使用方法。(此时由教师讲解集成开发环境的相关用法)

(6)输入并运行一个简单的、正确的程序。 输入下面的程序(教材第1章例1.1) #include void main() {

printf(“This is a c program.\\n”); }

① 对源程序进行编译,观察屏幕上显示的编译信息。如果出现“出错信息”,则应找出原

因并改正之,再进行编译,如果无错,则进行连接。 ② 如果编译连接无错误,使程序运行,观察分析运行结果。 (7)试编辑一个程序,使之能输出以下内容:(选做题)

****** ****** ********** ********** ************* ************* ***************************** ***************************** ***************************** *************************** *********************** ******************* *************** *********** ******* *** *

(8)输入并编辑一个有错误的C程序。

①输入以下程序(教材第1章中例1.2,故意漏打或打错几个字符)。、 #include void main() {int a,b,sum

a = 123; b = 456; sum=a+b

printf(“sum is %d \\n”,sum); }

② 进行编译,仔细分析编译信息窗口,可能显示有多个错误,逐个修改,直到不出现错误。

最后请与教材上的程序对照。 ③ 使程序运行,分析运行结果。

(9) 试参照以上程序编辑一个程序,求两个数之差。

*******************************************************************************以下上机步骤为提高部分 *

dstandardizationofsafetyproduction,andstrivetoachieve\nsicallysafe\safetysectionandisaunitofsecurityofficersresponsibleforminesafetydutiesandsupervisetheimplementationofthefollow-upto,andimplementationofthesystem,prosecution.PartImanagementsystems...Youcanusebrazierswhen,2--3metersfromthegroundandputthefireoutbeforethework,confirmthenofirebeforetheycanleave;Highway11non-staffinthemarginwithin50m,radiusoftheexcavationwork,andworkingwithin6metresoftheedgeandstayundertheumbrellaheading;12,blastingintothepitpersonnelmustfollowtheshootingguard'scommand,hidetosafety;13non-miningvehicles(includingbicycles,animal-drawnvehicle,motorvehicles,etc)willbebannedfromenteringthepitsandotherproductionareaonpainofheavyfines,resultinginaccidentstobeinvestigatedforresponsibility;14shootingthefollowingmechanicalsafetydistancesasfollows:categorynamemechanicalcannonsshallowholesandpopshootingexposedblastingunits:metersdiggingmachinerigcargunpowderotherequipment-pitequipment,especiallyanelectricalswitchandavarietyofsafetydevices,inadditiontospecifyingtheuseofresponsiblepersonnel,bananytouchingofotherpersonnel;16foundthatpowerlinesorcablesbreakinggroundbeforewithoutascertainingwhetherthecharged,prohibitsanyonefromtouching,andshouldleave5metersaway,andimmediatelynotifythepersonchecking;17withouttheleadership'sconsent,arenotallowedtotakethestrippedtrucks,watertankers,oiltankers,asaresultofthecau ******************************************************************************* (10)输入并运行一个需要在运行时输入数据的程序。 ①输入下面的程序: #include void main()

{int min(int x,int y); int a,b,c;

printf(“input a & b:”); scanf(“%d,%d”,&a,&b); c = min(a,b);

printf(“min=%d\\n”,c); }

int min(int x,int y) {int z;

if (x

②编译并运行,在运行时从键盘输入整数2和5,然后按“回车”键,观察运行结果。 ③将程序中的第3行改为 int a;b;c;

再进行编译,观察其结果。

④将max函数中的第3、4两行合并写为一行,即 if(x>y) z=x; else z=y;

进行编译和运行,分析结果。

3.预习内容:《C程序设计》(第二版)第1章。

实验2 数据类型、运算符和表达式

1.实验目的

(1)掌握C语言数据类型,熟悉如何定义一个整型、字符型和实型的变量,以及对它们赋值的方法。

(2)掌握二进制、八进制、十进制、十六进制之间的转换。

(3)掌握用Windows自带的计算器工具,进行各种数据之间的转换。 (4)掌握不同的类型数据之间赋值的规律。

(5)学会使用C的有关算术运算符,以及包含这些运算符的表达式,特别是自加(++)和自减(――)运算符的使用。

(6)进一步熟悉C程序的编辑、编译、连接和运行的过程。 2.实验内容和步骤

*******************************************************************************

以下为第一次两课时上机内容

*******************************************************************************

(1)将下面各数用八进制和十六进制数表示 十进制数 八进制数 十六进制数 十进制数 八进制数 十六进制数 10 -111 32 2483 75 -28654 dstandardizationofsafetyproduction,andstrivetoachieve\nsicallysafe\safetysectionandisaunitofsecurityofficersresponsibleforminesafetydutiesandsupervisetheimplementationofthefollow-upto,andimplementationofthesystem,prosecution.PartImanagementsystems...Youcanusebrazierswhen,2--3metersfromthegroundandputthefireoutbeforethework,confirmthenofirebeforetheycanleave;Highway11non-staffinthemarginwithin50m,radiusoftheexcavationwork,andworkingwithin6metresoftheedgeandstayundertheumbrellaheading;12,blastingintothepitpersonnelmustfollowtheshootingguard'scommand,hidetosafety;13non-miningvehicles(includingbicycles,animal-drawnvehicle,motorvehicles,etc)willbebannedfromenteringthepitsandotherproductionareaonpainofheavyfines,resultinginaccidentstobeinvestigatedforresponsibility;14shootingthefollowingmechanicalsafetydistancesasfollows:categorynamemechanicalcannonsshallowholesandpopshootingexposedblastingunits:metersdiggingmachinerigcargunpowderotherequipment-pitequipment,especiallyanelectricalswitchandavarietyofsafetydevices,inadditiontospecifyingtheuseofresponsiblepersonnel,bananytouchingofotherpersonnel;16foundthatpowerlinesorcablesbreakinggroundbeforewithoutascertainingwhetherthecharged,prohibitsanyonefromtouching,andshouldleave5metersaway,andimmediatelynotifythepersonchecking;17withouttheleadership'sconsent,arenotallowedtotakethestrippedtrucks,watertankers,oiltankers,asaresultofthecau -617 21003 1 请自行计算各数据表示表式,再将其填入上表中。 2 点击:开始->所有程序->附件->计算器,打开计算器程序,点击查看->科学型,

试用计算机验证以上计算结果是否正确。

(2)请认真研究图1所示程序,并回答问题 1 请分析该程序的输出是什么?并写在下面

2 输入并运行该程序,将运行结果写在下面?

③试分析你的分析结果和运行结果一样吗? 如果不一样,为什么?

(3) 请认真研究图2所示程序,并回答问题

1 请分析该程序的输出是什么?并写在下面 2 输入并运行该程序,将运行结果写在下面?

③试分析你的分析结果和运行结果一样吗?

如果不一样,为什么? (4)输入并运行图3所示程序: 1 运行此程序。

2 在上面printf语句下面再增加一个printf语句:

printf(\再运行,并分析结果。 ③将第3行改为

int c1,c2;

再使之运行,并观察结果。

④再将第4、5行改为:

c1 = a; /*不用单撇号*/ c2 = b;

再使之运行,分析其运行结果。 ⑤再将第4、5行改为 c1 = \ /*用双撇号*/ c2 = \

再使之运行,分析其运行结果。 ⑥再将第4、5行改为:

c1=300; /*用大于255的整数*/ c2=400;

#include void main() {short a,b; a=32767; b=a+1; printf(\} 图1 #include void main() {float a,b; a=.89e5; b=a+30; printf(\} 图2 #include void main() {char c1,c2; c1='a'; c2='b'; printf(\} 图3 dstandardizationofsafetyproduction,andstrivetoachieve\nsicallysafe\safetysectionandisaunitofsecurityofficersresponsibleforminesafetydutiesandsupervisetheimplementationofthefollow-upto,andimplementationofthesystem,prosecution.PartImanagementsystems...Youcanusebrazierswhen,2--3metersfromthegroundandputthefireoutbeforethework,confirmthenofirebeforetheycanleave;Highway11non-staffinthemarginwithin50m,radiusoftheexcavationwork,andworkingwithin6metresoftheedgeandstayundertheumbrellaheading;12,blastingintothepitpersonnelmustfollowtheshootingguard'scommand,hidetosafety;13non-miningvehicles(includingbicycles,animal-drawnvehicle,motorvehicles,etc)willbebannedfromenteringthepitsandotherproductionareaonpainofheavyfines,resultinginaccidentstobeinvestigatedforresponsibility;14shootingthefollowingmechanicalsafetydistancesasfollows:categorynamemechanicalcannonsshallowholesandpopshootingexposedblastingunits:metersdiggingmachinerigcargunpowderotherequipment-pitequipment,especiallyanelectricalswitchandavarietyofsafetydevices,inadditiontospecifyingtheuseofresponsiblepersonnel,bananytouchingofotherpersonnel;16foundthatpowerlinesorcablesbreakinggroundbeforewithoutascertainingwhetherthecharged,prohibitsanyonefromtouching,andshouldleave5metersaway,andimmediatelynotifythepersonchecking;17withouttheleadership'sconsent,arenotallowedtotakethestrippedtrucks,watertankers,oiltankers,asaresultofthecau 再使之运行,分析其运行结果。

本文来源:https://www.bwwdw.com/article/ktqf.html

Top