# CMSC 104, Section 01, Fall 2016 Problem Solving and Computer Programming

## Lab - Looping & Numerics

Due Date: Tuesday, November 15th @ 6:45 PM

Point Value: This lab is worth 5 points extra credit!

Objectives:

To become more familiar with:
• C program creation, compilation, and execution
• Looping Concepts
• Assignment and Comparison operators

Write a program, better_stats.c, that continually asks the user to enter numeric values from the keyboard. After each value is entered, the following summary statistics are shown, then the user is prompted to enter another value:
• The Sum
• The Product
• The Average
• The Smallest Number
• The Largest Number
The user can quit the program at any time by entering the sentinel value -1.

HINT: to tell printf to only print the maximum number of floating point digits needed, use %g instead of %f.

Example output:
```\$ gcc -Wall -ansi better_stats.c
\$ ./a.out
Enter a number: 5
Sum      = 5
Product  = 5
Average  = 5
Smallest = 5
Largest  = 5

Enter a number: 6
Sum      = 11
Product  = 30
Average  = 5.5
Smallest = 5
Largest  = 6

Enter a number: 7
Sum      = 18
Product  = 210
Average  = 6
Smallest = 5
Largest  = 7

Enter a number: -2.25
Sum      = 15.75
Product  = -472.5
Average  = 3.9375
Smallest = -2.25
Largest  = 7

Enter a number: -1
\$
```

When you have finished, call the instructor and show him the source code and output of your program.

Last Modified: November 12th, 2016 11:42 AM