Lecture 4 - Testing and Decision Making

Back to Previous Lecture
Up to Main Page
Forward to Next Lecture

Comparing Two Numbers

The program compare.c gets two numbers from the user, and then determines which one is the bigger of the two.

Sales Tax

The program tax.c shows how to calculate sales tax of six percent. The program tax2.c adds some bells and whistles.

Calculator

The program calc.c gets two numbers from the user, along with an operation. If the user enters a valid operation (one that the program is looking for), then the result is calculated and displayed.

Getting Information From the User

The program getinfo.c is an improvement on the program from the last two lectures. In this version, we check to see if the user entered too many characters for a name. If so, then we truncate the string the user entered by inserting a binary zero in what will be the last position in the name string. (Since names are NAMESIZ long, the entries go from 0 to NAMESIZ-1.)

Back to Previous Lecture
Up to Main Page
Forward to Next Lecture