This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
haas:spring2020:cprog:projects:cnv0 [2020/03/27 12:18] – created wedge | haas:spring2020:cprog:projects:cnv0 [2020/03/27 14:08] (current) – [Verification] wedge | ||
---|---|---|---|
Line 10: | Line 10: | ||
=====Reading===== | =====Reading===== | ||
- | In "The C Book", please read through Chapter 6. | + | In [[https:// |
=====Background===== | =====Background===== | ||
Line 89: | Line 89: | ||
=====Program===== | =====Program===== | ||
- | It is your task to write a program that, upon accepting various pieces of input from the user, computes the number of factor pairs of a given number or range of numbers, displaying to STDOUT all the numbers in that range that qualify as a secondary number. | + | It is your task to write a program that, upon accepting various pieces of input from the user, computes the number of factor pairs of a given number or range of numbers, displaying to STDOUT all the numbers in that range that qualify as that N-ary value. |
=====Specifications===== | =====Specifications===== | ||
Line 102: | Line 102: | ||
* argv[2]: lower-bound (where to start processing, inclusive of the lower bound value); this should be stored in an **unsigned short int** | * argv[2]: lower-bound (where to start processing, inclusive of the lower bound value); this should be stored in an **unsigned short int** | ||
* argv[3]: upper-bound (where to stop processing, inclusive of the upper bound value); this should be shored in an **unsigned short int** | * argv[3]: upper-bound (where to stop processing, inclusive of the upper bound value); this should be shored in an **unsigned short int** | ||
- | * immediately after the input, check to make sure the specified parameters are positive numbers: | + | * immediately after parameter processing, check to make sure the specified parameters are positive numbers. Any deviations should be displayed as error messages to STDERR: |
* N-ary value must be between 1 and 16 (inclusive of 1 and 16) | * N-ary value must be between 1 and 16 (inclusive of 1 and 16) | ||
+ | * on error display " | ||
* lower bound must be between 2 and 40000 (inclusive of 2 and 40000) | * lower bound must be between 2 and 40000 (inclusive of 2 and 40000) | ||
+ | * on error display " | ||
* upper bound must be between 2 and 65000 (inclusive of 2 and 65000) | * upper bound must be between 2 and 65000 (inclusive of 2 and 65000) | ||
+ | * on error display " | ||
+ | * on situation of lower bound being greater than upper bound, display " | ||
* proceed to evaluate the appropriate number range, determining whether or not it is an N-ary number of runtime specification | * proceed to evaluate the appropriate number range, determining whether or not it is an N-ary number of runtime specification | ||
- | * if it is, display the value to STDOUT in space-separated form (see execution section below for message) | + | * if it is, display the value to STDOUT in space-separated form (see execution section below for format) |
* if it is not, do not display anything related to that value (again, see execution section below) | * if it is not, do not display anything related to that value (again, see execution section below) | ||
* using a single return statement at the conclusion of the code, return a 0 indicating successful operation | * using a single return statement at the conclusion of the code, return a 0 indicating successful operation | ||
- | * for all error results, use **exit()** instead; there should only be exactly ONE **return()** statement | + | * for all error results, use **exit()** instead; there should only be exactly ONE **return()** statement |
Some additional points of consideration: | Some additional points of consideration: | ||
Line 117: | Line 121: | ||
=====Execution===== | =====Execution===== | ||
- | ====Secondary number output==== | + | ====Primary number (nary(1)) output==== |
+ | < | ||
+ | lab46: | ||
+ | 11 13 17 19 23 | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | ====Secondary number | ||
<cli> | <cli> | ||
lab46: | lab46: | ||
- | 4 6 8 9 10 | + | 4 6 8 9 10 |
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | ====Tertiary number (nary(3)) output==== | ||
+ | < | ||
+ | lab46: | ||
+ | 12, 16, 18, 20, 28, 32 | ||
lab46: | lab46: | ||
</ | </ | ||
Line 147: | Line 165: | ||
<cli> | <cli> | ||
- | lab46: | + | lab46: |
- | [ 1] you have: err, should be: err [ 2] you have: no, should be: no | + | ERROR CHECK |
- | [ 3] you have: no, should be: | + | ================= |
- | [ 5] you have: no, should be: | + | invalid nary (0): ERROR: invalid nary value (0)! |
- | [ 7] you have: no, should be: | + | exit status: 1, should be: 1 |
- | [ 9] you have: yes, should be: yes [ 10] you have: yes, should be: yes | + | - - - - - - - |
- | [ 11] you have: no, should be: | + | invalid nary (17): ERROR: invalid nary value (17)! |
- | [ 13] you have: no, should be: | + | exit status: 1, should be: 1 |
- | [ 15] you have: yes, should be: yes [ 16] you have: no, should be: no | + | - - - - - - - |
- | [ 17] you have: no, should be: no [ 18] you have: no, should be: no | + | invalid lower (1): ERROR: invalid lower bound (1)! |
- | [ 19] you have: no, should be: no [ 20] you have: no, should be: no | + | exit status: 2, should be: 2 |
- | [ 21] you have: yes, should be: yes [ 22] you have: yes, should be: yes | + | - - - - - - - |
- | [ 23] you have: no, should be: no [ 24] you have: no, should be: no | + | invalid lower (43100): ERROR: invalid lower bound (43100)! |
- | [ 25] you have: yes, should be: yes [ 26] you have: yes, should be: yes | + | exit status: 2, should be: 2 |
- | [ 27] you have: yes, should be: yes [ 28] you have: no, should be: no | + | - - - - - - - |
- | [ 29] you have: no, should be: no [ 30] you have: no, should be: no | + | invalid upper (0): ERROR: invalid upper bound (0)! |
- | [ 31] you have: no, should be: no [ 32] you have: no, should be: no | + | exit status: 3, should be: 3 |
- | [ 33] you have: yes, should be: yes [ 34] you have: yes, should be: yes | + | - - - - - - - |
- | [ 35] you have: yes, should be: yes [ 36] you have: no, should be: no | + | invalid upper (65501): ERROR: invalid upper bound (65501)! |
- | lab46: | + | exit status: 3, should be: 3 |
+ | - - - - - - - | ||
+ | lower (300) bigger than upper (65): ERROR: lower bound (300) is larger than upper bound (65)! | ||
+ | exit status: 4, should be: 4 | ||
+ | - - - - - - - | ||
+ | Press ENTER to continue verification tests | ||
+ | nary( 1) | ||
+ | ======== | ||
+ | have: >23 29 31 < | ||
+ | need: >23 29 31 < | ||
+ | |||
+ | nary( 2) | ||
+ | ======== | ||
+ | have: >21 22 25 26 27 33 34 35 < | ||
+ | need: >21 22 25 26 27 33 34 35 < | ||
+ | |||
+ | nary( 3) | ||
+ | ======== | ||
+ | have: >20 28 32 < | ||
+ | need: > | ||
+ | |||
+ | nary( 4) | ||
+ | ======== | ||
+ | have: > | ||
+ | need: >24 30 < | ||
+ | |||
+ | nary( 5) | ||
+ | ======== | ||
+ | have: >36 < | ||
+ | need: >36 < | ||
+ | |||
+ | lab46: | ||
</ | </ | ||