User Tools

Site Tools


haas:fall2019:c4eng:projects:mtf1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
haas:fall2019:c4eng:projects:mtf1 [2019/09/23 13:09] – [Submission] wedgehaas:fall2019:c4eng:projects:mtf1 [2019/10/01 12:06] – [Execution] wedge
Line 13: Line 13:
  
 =====Program===== =====Program=====
-It is your task to enhance the program you wrote last week (**mtf0**) that will use loops and other programming concepts learned this far to automate the display of entire mathematical operation tables (addition, subtraction, multiplication, or division; as indicated by the user). This information is potentially of value to some of your letter division efforts in the pctX projects.+It is your task to enhance the program you wrote last week (**mtf0**) that will use loops and other programming concepts learned this far to automate the display of entire mathematical operation tables (addition, subtraction, multiplication, division, or remainder; as indicated by the user). This information is potentially of value to some of your letter division efforts in the pctX projects.
  
 +=====Specifications=====
 Your program should: Your program should:
 +
   * have valid, descriptive variable names of length //no shorter than// 4 symbols   * have valid, descriptive variable names of length //no shorter than// 4 symbols
 +    * I will make an exception for the use of 'row'
   * prompt the user for the operation ('+' for addition, '-' for subtraction, '*' for multiplication, '/' for division, and '%' for remainder)   * prompt the user for the operation ('+' for addition, '-' for subtraction, '*' for multiplication, '/' for division, and '%' for remainder)
     * properly store this in a variable of type **char**     * properly store this in a variable of type **char**
     * check for a literal '+', '-', '*', or '/' symbol to determine operation to perform     * check for a literal '+', '-', '*', or '/' symbol to determine operation to perform
-      * if invalid input, display an error and exit with a non-zero value+      * if invalid input, display an error and exit with a non-zero value of 1
   * prompt for the starting row (0-9)   * prompt for the starting row (0-9)
     * properly store this in a variable of type **unsigned char**     * properly store this in a variable of type **unsigned char**
Line 30: Line 33:
     * properly store this in a variable of type **unsigned char**     * properly store this in a variable of type **unsigned char**
   * check to make sure starting column, row is less than or equal to the corresponding ending column, row   * check to make sure starting column, row is less than or equal to the corresponding ending column, row
-    * if not, display an error (to STDERR) and exit with non-zero status code+    * if not, display an error (to STDERR) and exit with non-zero status code of 2 (for row) or 3 (for column)
   * display the table, performing the indicated operation   * display the table, performing the indicated operation
     * display both row and column headers, in uniform fashion/formatting throughout     * display both row and column headers, in uniform fashion/formatting throughout
Line 42: Line 45:
   * Only the table (headers/dividers included)should be output to STDOUT. Everything else (the input prompts) should be displayed to STDERR.   * Only the table (headers/dividers included)should be output to STDOUT. Everything else (the input prompts) should be displayed to STDERR.
   * For the math operations that are not associative, the row value is the one to be operated against (ie result=row-col).   * For the math operations that are not associative, the row value is the one to be operated against (ie result=row-col).
 +  * To display a '%' character using fprintf, repeat it: %%. That will cancel the otherwise substitutive properties of the symbol in the context of fprintf.
 +=====Compiling=====
 +As we have been doing all along, use the following options to gcc when compiling:
 +
 +<cli>
 +lab46:~/src/c4eng/mtf1$ gcc -Wall --std=gnu99 -o mtf1 mtf1.c
 +lab46:~/src/c4eng/mtf1$ 
 +</cli>
 +
 =====Execution===== =====Execution=====
  
 ====Sample run using multiplication==== ====Sample run using multiplication====
 <cli> <cli>
-lab46:~/src/c4eng/mtf1$ ./mtfX+lab46:~/src/c4eng/mtf1$ ./mtf1
 Which operation: * Which operation: *
 Starting Row (0-9): 4 Starting Row (0-9): 4
Line 185: Line 197:
 *:mtf1:correct variable types and name lengths used [13/13] *:mtf1:correct variable types and name lengths used [13/13]
 *:mtf1:proper output formatting per specifications [13/13] *:mtf1:proper output formatting per specifications [13/13]
-*:mtf1:submission conforms to project specifications [13/13] 
 *:mtf1:runtime tests of submitted program succeed [13/13] *:mtf1:runtime tests of submitted program succeed [13/13]
 *:mtf1:no negative compiler messages for program [13/13] *:mtf1:no negative compiler messages for program [13/13]
haas/fall2019/c4eng/projects/mtf1.txt · Last modified: 2019/10/01 12:07 by wedge