1 / 11

C 语言程序设计实验

C 语言程序设计实验. 实验三 选择结构程序设计. 实验目的及要求 1 、进一步理解逻辑量的表示方法。 2 、掌握 C 语言的逻辑运算符及逻辑表达式的正确使用。 3 、熟练掌握 if 语句与 switch 语句的正确应用。. 实验环境 TurboC2.0. 上机运行步骤 ①打开 TC ,用 F10 键选择“ FILE”—“NEW” 在 C 中编辑源文件 ②选择“ FILE” —“SAVE” 命令,将文件保存为扩展名为 .C 的文件

maxime
Download Presentation

C 语言程序设计实验

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C语言程序设计实验

  2. 实验三 选择结构程序设计

  3. 实验目的及要求 1、进一步理解逻辑量的表示方法。 2、掌握C语言的逻辑运算符及逻辑表达式的正确使用。 3、熟练掌握if 语句与switch语句的正确应用。

  4. 实验环境 TurboC2.0

  5. 上机运行步骤 ①打开TC,用F10键选择“FILE”—“NEW”在C中编辑源文件 ②选择“FILE” —“SAVE”命令,将文件保存为扩展名为 .C的文件 ③选择“COMPILE”—“COMPILE TO OBJ”调试,选择“RUN”—“RUN”运行,选择“RUN”—“USER SCREEN”查看运行结果。

  6. 实验内容 1、 调试下列程序,使之具有如下功能:输入a、b、c三个整数,求最小值。写出调试过程。   程序中包含有一些错误,将其输入并调试程序,分析错误原因,将正确结果写出。

  7. main() { int a,b,c;scanf("%d%d%d",a,b,c); if((a>b)&&(a>c)) if(b<c) printf("min=%d\n",b); else printf("min=%d\n",c); if((a<b)&&(a<c))printf("min=%d\n",a); }

  8. 2、 编写程序,求解下列分段函数:    

  9. 3、 从键盘上输入字符,输出时判别其分类:控制符、数字、大写字母、小写字母、其他字符。(可以根据输入字符的ASCII码来判别类型)

  10. 4、 某托儿所收2岁到6岁的孩子,2岁、3岁孩子进小班(Lower class);4岁孩子进中班(Middle class);5岁、6岁孩子进大班(Higher class)。编写程序(用switch语句),输入孩子年龄,输出年龄及进入的班号。 如:输入:3,输出:age:3,enter Lower class。

  11. 实验总结 将源程序、目标文件、可执行文件和实验报告存在服务器的指定文件夹中。 运行程序并记录运行结果。 分析调试程序过程中所出现的错误并加以修改。

More Related