User Tools

Site Tools


haas:spring2020:cprog:projects:cnv0

Differences

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

Link to this comparison view

Next revision
Previous revision
haas:spring2020:cprog:projects:cnv0 [2020/03/27 12:18] – created wedgehaas: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://lab46.g7n.org/_media/haas/the_c_book.pdf|"The C Book"]], please read through Chapter 6.
  
 =====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 "ERROR: invalid nary value (#)!" and terminate execution sending back a 1 (the # should be the actual number in deviation)
     * 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 "ERROR: invalid lower bound (#)!" and terminate execution sending back a 2 (the # should be the actual number in deviation)
     * 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 "ERROR: invalid upper bound (#)!" and terminate execution sending back a 3 (the # should be the actual number in deviation)
 +      * on situation of lower bound being greater than upper bound, display "ERROR: lower bound (#) is larger than upper bound (#)!", terminating execution and sending back a 4 (the # should be the actual number in deviation)
   * 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 in your entire program+    * for all error results, use **exit()** instead; there should only be exactly ONE **return()** statement per function
  
 Some additional points of consideration: Some additional points of consideration:
Line 117: Line 121:
 =====Execution===== =====Execution=====
  
-====Secondary number output====+====Primary number (nary(1)) output==== 
 +<cli> 
 +lab46:~/src/cprog/cnv0$ ./cnv0 1 8 24 
 +11 13 17 19 23  
 +lab46:~/src/cprog/cnv0$  
 +</cli> 
 + 
 +====Secondary number (nary(2)) output====
 <cli> <cli>
 lab46:~/src/cprog/cnv0$ ./cnv0 2 3 12 lab46:~/src/cprog/cnv0$ ./cnv0 2 3 12
-4 6 8 9 10+4 6 8 9 10  
 +lab46:~/src/cprog/cnv0$  
 +</cli> 
 + 
 +====Tertiary number (nary(3)) output==== 
 +<cli> 
 +lab46:~/src/cprog/cnv0$ ./cnv0 3 11 37 
 +12, 16, 18, 20, 28, 32 
 lab46:~/src/cprog/cnv0$  lab46:~/src/cprog/cnv0$ 
 </cli> </cli>
Line 147: Line 165:
  
 <cli> <cli>
-lab46:~/src/c4eng/cnv0$ /var/public/spring2020/cprog/cnv0/cnv0verify +lab46:~/src/cprog/cnv0$ /var/public/spring2020/cprog/cnv0/cnv0verify 
-[  1] you haveerr, should beerr    [  2] you have no, should be:  no +ERROR CHECK 
-[  3] you have no, should be no    [  4] you haveyes, should be: yes +================= 
-[  5] you have no, should be no    [  6] you haveyes, should be: yes +invalid nary (0)ERRORinvalid nary value (0)! 
-[  7] you have no, should be no    [  8] you haveyes, should be: yes +     exit status1, should be: 
-[  9] you haveyes, should beyes    [ 10] you haveyes, should be: yes +- - - - - - - 
-[ 11] you have no, should be no    [ 12] you have no, should be:  no +invalid nary (17)ERRORinvalid nary value (17)! 
-[ 13] you have no, should be no    [ 14] you haveyes, should be: yes +     exit status1, 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)ERRORinvalid lower bound (1)! 
-[ 19] you have:  no, should be:  no    [ 20] you have:  no, should be:  no +     exit status2, 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)ERRORinvalid lower bound (43100)! 
-25] you have: yes, should be: yes    [ 26] you have: yes, should be: yes +     exit status2, should be: 2 
-[ 27] you haveyes, 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)ERRORinvalid upper bound (0)! 
-[ 31] you have no, should be:  no    [ 32] you have:  no, should be:  no +     exit status3, should be: 3 
-[ 33] you have: yes, should be: yes    [ 34] you have: yes, should be: yes +- - - - - - - 
-[ 35] you have: yes, should beyes    [ 36] you have:  no, should be:  no +invalid upper (65501)ERRORinvalid upper bound (65501)! 
-lab46:~/src/c4eng/cnv0$ +     exit status3, should be: 3 
 +- - - - - - - 
 +lower (300) bigger than upper (65)ERRORlower bound (300) is larger than upper bound (65)! 
 +     exit status4, 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>20 28 32 < 
 + 
 +nary( 4) 
 +======== 
 +   have: >24 30 < 
 +   need>24 30 < 
 + 
 +nary( 5) 
 +======== 
 +   have: >36 < 
 +   need>36 
 + 
 +lab46:~/src/cprog/cnv0$ 
 </cli> </cli>
  
haas/spring2020/cprog/projects/cnv0.1585311517.txt.gz · Last modified: 2020/03/27 12:18 by wedge