Assignment 7.docx-2
Assignment 7.docx-2
You are to write a program that will allow a user to enter infinite numbers (one number at a
time and all numbers are greater than zero). You must have a way for the user to stop entering
values. Once the user stops, you will immediately display the following:
The lowest number was:
The highest number was:
The number of values entered was:
The average of the numbers was:
1. IPO or Flowchart for the problem.
Input Process Output
Random numbers Write a program that will The lowest number was:
allow a user to enter
infinite numbers (one The highest number was:
number at a time and all
numbers are greater than The number of values
zero). Have a way for the entered was:
user to stop entering
values. The average of the
Once the user stops, numbers was:
display the following:
- The lowest number was:
- The highest number was:
- The number of values
entered was:
- The average of the
numbers was:
2. A test case sheet that shows 3 sets of input data, and the expected results of running the
program for each set of input data:
TEST CASE 1:
This study source was downloaded by 100000831727298 from CourseHero.com on 04-03-2022 09:34:40 GMT -05:00
https://www.coursehero.com/file/58907510/-Assignment-7docx/
TEST CASE 2:
/*Write a program that will allow a user to enter infinite numbers (one number at
a time
and all numbers are greater than zero). Have a way for the user to stop entering
values.
Once the user stops, display the following:
- The lowest number was:
- The highest number was:
- The number of values entered was:
- The average of the numbers was:*/
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
//Declared variables
int number, lowNum = 0, highNum = 0, sum = 0, totalValues = 0;
double average;
https://www.coursehero.com/file/58907510/-Assignment-7docx/
while (number != -1) //As the user inputs numbers, he/she can stop by
entering -1
{
if (number > highNum)
{ /*If the variable number is greater than the variable
highNum, then the highest number will be displayed*/
highNum = number;
}
sum = sum + number; /*The numbers that were entered by the user and
added together to get a total sum*/
printf("The lowest number was: %i \n", lowNum); //The lowest number will be
displayed
printf("The highest number was: %i \n", highNum); //The highest number will
be displayed
printf("The number of values entered was: %i \n",totalValues); //Shows how
many values were
entered
printf("The average of the numbers was: %.2lf \n", average); //Displays the
average of the
numbers
system("pause");
return 0;
}
4. Screen shots of running the program 3 different times. Use each of the test cases that
you have created.
This study source was downloaded by 100000831727298 from CourseHero.com on 04-03-2022 09:34:40 GMT -05:00
https://www.coursehero.com/file/58907510/-Assignment-7docx/
This study source was downloaded by 100000831727298 from CourseHero.com on 04-03-2022 09:34:40 GMT -05:00
https://www.coursehero.com/file/58907510/-Assignment-7docx/
Powered by TCPDF (www.tcpdf.org)