Program 4 - / preprocessors #include #define TRUE...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 // preprocessors #include <stdio.h> // to make use of printf and scanf #define TRUE 1 #define FALSE 0 // function prototypes int getDimensions( double* pWidth, double* pHeight, double* pLength ) double calculateArea( double width, double height, double length ) double calculateVolume( double width, double height, double length ) void printAreaReport( double width, double height, double length, double area ) void printVolumeReport( double width, double height, double length, double volume ) int getMenuChoice( int flag ) /******************************************************************* * * Main. It initializes the local variables. It runs a while * loop to know when to exit. It calls functions based on the * menu choice. * *******************************************************************/ int main( void ) // begin main { // initialize local variables double width = 0.0 double height = 0.0 double length = 0.0 double area = 0.0 double volume = 0.0 int choice = 0 int flag = FALSE while ( choice != 4) // begin while loop. Loop while choice is not "exit" { // call function getMenuChoice choice = getMenuChoice( flag ) if ( choice == 1) // if user chose choice 1 { // call function getDimension. Also sets "flag" to TRUE } else if ( choice == 2 && flag == TRUE ) // if user chose choice 2, and // dimensions have been input {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sheet1 Page 2 // calculate the area and print the dimensions and answer area = calculateArea( width, height, length ) printAreaReport( width, height, length, area )
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/15/2008 for the course CPT S 251 taught by Professor Warnick during the Spring '08 term at Washington State University .

Page1 / 10

Program 4 - / preprocessors #include #define TRUE...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online