User Tools

Site Tools


haas:fall2020: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:fall2020:cprog:projects:cnv0 [2020/03/27 10:08] – external edit 127.0.0.1haas:fall2020:cprog:projects:cnv0 [2020/10/08 11:04] (current) – [Submission] wedge
Line 7: Line 7:
  
 =====Objective===== =====Objective=====
-To create a program that can calculate and determine the number of factor pairs (nary value) over a given range of numbers.+To create a program that can calculate and determine the number of factor pairs of a given number, starting with values composed of exactly 2 sets of factor pairs.
  
 =====Reading===== =====Reading=====
-In [[https://lab46.g7n.org/_media/haas/the_c_book.pdf|"The C Book"]], please read through Chapter 6.+In "The C Book", please read through Chapter 8. 
 + 
 +Review needed concepts in [[https://www.tutorialspoint.com/cprogramming/|this tutorial]] and also [[https://www.cprogramming.com/tutorial/c-tutorial.html?inl=hp|this one]]
  
 =====Background===== =====Background=====
Line 87: Line 89:
  
 Because there are 3 factor pairs, 12 would be considered an nary(3) value (or a tertiary number). Because there are 3 factor pairs, 12 would be considered an nary(3) value (or a tertiary number).
 +
 +=====grabit=====
 +There is a grabit for this project, which will provide you with some files pertinent for performing this project.
 +
 +Run '**grabit**' on lab46 in the appropriate manner to obtain the files.
 +
 +=====Compiling=====
 +Since there is a provided Makefile in the project grabit, we can use that to compile, either regularly:
 +
 +<cli>
 +yourpi:~/src/cprog/cnv0$ make
 +</cli>
 +
 +Or, with debugging support:
 +
 +<cli>
 +yourpi:~/src/cprog/cnv0$ make debug
 +</cli>
  
 =====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 that N-ary value.+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, displaying its eligibility as a secondary number.
  
 =====Specifications===== =====Specifications=====
Line 97: Line 117:
   * have consistent, well-defined indentation (no less than 4 spaces per level of indentation)   * have consistent, well-defined indentation (no less than 4 spaces per level of indentation)
     * all code within the same scope aligned to its indentation level     * all code within the same scope aligned to its indentation level
-  * have proximal comments explaining your rationale and what is going on, throughout your code +  * have proximal comments explaining your rationale (the why and how), throughout your code 
-  * from the command-line, obtain the needed parameters for your program (require these arguments to be present, displaying errors to STDERR and exiting if they are not present): +  * to STDERR, prompt for the number (range appropriate of an unsigned long int) 
-    * argv[1]: N-ary value (how many factor pairs are we requiring; 1 for primefor secondary, 3 for tertiary, etc.); this should be stored and managed as an **unsigned char**. +    * properly store this in a variable of type **unsigned long int** 
-    * argv[2]: lower-bound (where to start processing, inclusive of the lower bound value); this should be stored in an **unsigned short int** +  * immediately after the input, check to make sure the input number is positive number greater than or equal to 2; if in violation, display an error (to STDERR) and exit with non-zero value. 
-    * argv[3]: upper-bound (where to stop processing, inclusive of the upper bound value); this should be shored in an **unsigned short int** +  * proceed to evaluate the input number, determining whether or not it is a secondary (nary(2)) number. 
-  * immediately after parameter processing, check to make sure the specified parameters are positive numbers. Any deviations should be displayed as error messages to STDERR: +    * if it is, display to STDOUT that it is a secondary number (see execution section below for message
-    * N-ary value must be between 1 and 16 (inclusive of 1 and 16) +    * if it is not, display to STDOUT that it is not a secondary number (again, see execution section below)
-      * 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) +
-      * on error display "ERROR: invalid lower bound (#)!" and terminate execution sending back 2 (the # should be the actual number in deviation) +
-    * upper bound must be between 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 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 +
-    * 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)+
   * 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 per function 
  
 Some additional points of consideration: Some additional points of consideration:
Line 121: Line 131:
 =====Execution===== =====Execution=====
  
-====Primary number (nary(1)) output====+====Secondary number output====
 <cli> <cli>
-lab46:~/src/cprog/cnv0$ ./cnv0 1 8 24 +yourpi:~/src/cprog/cnv0$ ./cnv0 
-11 13 17 19 23  +Enter a number: 6 
-lab46:~/src/cprog/cnv0$ +6 is a secondary number 
 +yourpi:~/src/cprog/cnv0$ 
 </cli> </cli>
  
-====Secondary number (nary(2)) output====+====Non-secondary number output====
 <cli> <cli>
-lab46:~/src/cprog/cnv0$ ./cnv0 2 3 12 +yourpi:~/src/cprog/cnv0$ ./cnv0 
-4 6 8 9 10  +Enter a number: 7 
-lab46:~/src/cprog/cnv0$ +7 is NOT a secondary number
 </cli> </cli>
  
-====Tertiary number (nary(3)) output====+====Additional outputs====
 <cli> <cli>
-lab46:~/src/cprog/cnv0$ ./cnv0 3 11 37 +yourpi:~/src/cprog/cnv0$ ./cnv0 
-12, 16, 18, 20, 28, 32  +Enter a number: 8 
-lab46:~/src/cprog/cnv0$ +8 is a secondary number 
 +yourpi:~/src/cprog/cnv0$ ./cnv0 
 +Enter a number: 16 
 +16 is NOT a secondary number 
 +yourpi:~/src/cprog/cnv0$ ./cnv0 
 +Enter a number: 21 
 +21 is a secondary number 
 +yourpi:~/src/cprog/cnv0$ 
 </cli> </cli>
  
 The execution of the program is short and simple- obtain the input, do the processing, produce the output, and then terminate. The execution of the program is short and simple- obtain the input, do the processing, produce the output, and then terminate.
- 
-=====Compiling===== 
-As we have been doing all along, use the following options to gcc when compiling: 
- 
-<cli> 
-lab46:~/src/cprog/cnv0$ gcc -Wall --std=gnu99 -o cnv0 cnv0.c 
-lab46:~/src/cprog/cnv0$  
-</cli> 
  
 =====Reference===== =====Reference=====
-In the CPROG public directory, inside the **cnv0** subdirectory, will be a copy of my implementation (in executable form, by the name **ref_cnv0**), which abides by the project specifications. Please compare its output against that of your implementation.+Copied as part of the grabit, inside your **cnv0/** subdirectory, will be a copy of my implementation (in executable form, by the name **ref_cnv0**), which abides by the project specifications. Please compare its output against that of your implementation. You can invoke the reference implementation by running the following:
  
 <cli> <cli>
-lab46:~/src/cprog/cnv0$ /var/public/spring2020/cprog/cnv0/ref_cnv0 2 2 40 +yourpi:~/src/cprog/cnv0$ make check 
-8 9 10 14 15 21 22 25 26 27 33 34 35 38 39 +Enter a number: 6 
-lab46:~/src/cprog/cnv0$ +is a secondary number 
 +yourpi:~/src/cprog/cnv0$ 
 </cli> </cli>
  
 =====Verification===== =====Verification=====
-In addition, I have also placed a **cnv0verify** script in that same subdirectory, which will test your program against a range of values, to determine overall correctness.+In addition, I have also placed a **cnv0verify** script in that same subdirectory, which will test your program against a range of values, to determine overall correctness. You can run the verify script using the Makefile, as follows:
  
 <cli> <cli>
-lab46:~/src/cprog/cnv0$ /var/public/spring2020/cprog/cnv0/cnv0verify +yourpi:~/src/cprog/cnv0$ make verify 
-ERROR CHECK +[  1] you haveerr, should beerr    [  2] you have no, should be:  no 
-================= +[  3] you have no, should be no    [  4] you haveyes, should be: yes 
-invalid nary (0)ERRORinvalid nary value (0)! +[  5] you have no, should be no    [  6] you haveyes, should be: yes 
-     exit status1, should be: +[  7] you have no, should be no    [  8] you haveyes, should be: yes 
-- - - - - - - +[  9] you haveyes, should beyes    [ 10] you haveyes, should be: yes 
-invalid nary (17)ERRORinvalid nary value (17)! +[ 11] you have no, should be no    [ 12] you have no, should be:  no 
-     exit status1, should be: +[ 13] you have no, should be no    [ 14] you haveyes, should be: yes 
-- - - - - - - +[ 15] you have: yes, should be: yes    [ 16] you have:  no, should be:  no 
-invalid lower (1)ERRORinvalid lower bound (1)! +[ 17] you have no, should be:  no    [ 18] you have:  no, should be:  no 
-     exit status2, should be: +[ 19] you have:  no, should be:  no    [ 20] you have:  no, should be:  no 
-- - - - - - - +21] you have: yes, should be: yes    [ 22] you have: yes, should be: yes 
-invalid lower (43100)ERRORinvalid lower bound (43100)! +[ 23] you have no, should be:  no    [ 24] you have:  no, should be:  no 
-     exit status2, should be: 2 +25] you have: yes, should be: yes    [ 26] you have: yes, should be: yes 
-- - - - - - - +[ 27] you haveyes, should be: yes    [ 28] you have:  no, should be:  no 
-invalid upper (0)ERRORinvalid upper bound (0)! +[ 29] you have:  no, should be:  no    [ 30] you have:  no, should be:  no 
-     exit status3, should be: 3 +[ 31] you have no, should be:  no    [ 32] you have:  no, should be:  no 
-- - - - - - - +[ 33] you have: yes, should be: yes    [ 34] you have: yes, should be: yes 
-invalid upper (65501)ERRORinvalid upper bound (65501)! +[ 35] you haveyes, should be: yes    [ 36] you have:  no, should be:  no 
-     exit status3, should be: 3 +yourpi:~/src/cprog/cnv0$ 
-- - - - - - - +
-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>
  
Line 223: Line 203:
   * Code must compile cleanly (no notes, warnings, nor errors)   * Code must compile cleanly (no notes, warnings, nor errors)
   * Output must be correct, and match the form given in the sample output above.   * Output must be correct, and match the form given in the sample output above.
-  * Code must be nicely and consistently indented, to show scope and maximize readability +  * Code must be nicely and consistently indented 
-  * Code must be well commented (why and how comments)+  * Code must be well commented
   * Do NOT double space your code. Group like statements together.   * Do NOT double space your code. Group like statements together.
   * Output Formatting (including spacing) of program must conform to the provided output (see above).   * Output Formatting (including spacing) of program must conform to the provided output (see above).
-  * Track/version the source code in your lab46 repository+  * Track/version the source code in repository
   * Submit a copy of your source code to me using the **submit** tool.   * Submit a copy of your source code to me using the **submit** tool.
  
Line 233: Line 213:
  
 <cli> <cli>
-$ submit cprog cnv0 cnv0.c +lab46:~/src/cprog/cnv0make submit
-Submitting cprog project "cnv0": +
-    -> cnv0.c(OK) +
- +
-SUCCESSFULLY SUBMITTED+
 </cli> </cli>
 +
 +And make sure you get no error messages.
  
 You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches. You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.
Line 245: Line 223:
  
 <code> <code>
-78:cnv0:final tally of results (78/78)+91:cnv0:final tally of results (91/91) 
 +*:cnv0:resources obtained via grabit by Sunday before deadline [13/13]
 *:cnv0:proper error checking and status reporting performed [13/13] *:cnv0:proper error checking and status reporting performed [13/13]
 *:cnv0:correct variable types and name lengths used [13/13] *:cnv0:correct variable types and name lengths used [13/13]
Line 257: Line 236:
   * Solutions not abiding by spirit of project will be subject to a 25% overall deduction   * Solutions not abiding by spirit of project will be subject to a 25% overall deduction
   * Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction   * Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction
-  * Solutions not utilizing consistent, sensible indentation to promote scope and clarity will be subject to a 25% overall deduction+  * Solutions not utilizing indentation to promote scope and clarity will be subject to a 25% overall deduction
   * Solutions not organized and easy to read are subject to a 25% overall deduction   * Solutions not organized and easy to read are subject to a 25% overall deduction
haas/fall2020/cprog/projects/cnv0.1585318105.txt.gz · Last modified: 2020/03/27 10:08 by 127.0.0.1