C语言程序设计—循环语句—实验报告

2023-04-27 04:16:12   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《C语言程序设计—循环语句—实验报告》,欢迎阅读!
程序设计,语句,循环,语言,实验

期:2014年10月16日 报告退发 (订正 、 重做) 课程 C程序设计实验 实验名称 循 环 语 句

一、实验目的

① 了解和掌握C语言中的循环语句;

② 掌握各类循环语句的区别和联系;

③ 掌握break以及continue的用法;

二、实验环境(描述实验的软件硬件环境)

软件环境:windows xp/win7等操作系统,Microsoft Visual C++ 6.0编译器;

硬件环境:PC机一台

三、实验内容、步骤和结果分析

题目一:编程找出用户输入的一串数值中的最大数。

要求:

(1)需要提示用户一个一个地输入数据;

(2)当用户输入一个不大于0的数值时,表示输入结束。此时应输出一串数值中的最大值;

#include<stdio.h>

float main()

{

float number,largest; printf(&uot;Please enter a positive number:&uot;); if(largest<=0) { } /*引导用户第一个数字输入为正数,以便正确执行本程序*/ for(number=1;number>0;) { printf(&uot;Please continue to enter a number:&uot;); scanf(&uot;%f&uot;,&number); if (number>=largest) { } largest=number; printf(&uot;Sorry,you enter a wrongful number!\nThe first number must be a positive num

本文来源:https://www.wddqxz.cn/37c3c34431126edb6e1a1044.html

相关推荐