User Tools

Site Tools


Sidebar

projects

wcp1 (due 20240828)
wcp2 (due 20240904)
pct0 (bonus; due 20240905)
pct1 (bonus; due 20240905)
pct2 (due 20240905)
abc0 (due 20240906)
gtf0 (due 20240911)
pct3 (bonus; due 20240911)
wcp3 (due 20240911)
dtr0 (due 20240918)
pct4 (due 20240918)
wcp4 (due 20240918)
mmf0 (due 20240926)
pct5 (bonus; due 20240926)
wcp5 (due 20240926)
cnv0 (due 20241002)
gfo0 (due 20241002)
pct6 (due 20241002)
wcp6 (due 20241002)
fwg0 (due 20241009)
pct7 (bonus; due 20241009)
wcp7 (due 20241009)
bwp1 (bonus; due 20241016)
cnv1 (due 20241016)
pct8 (due 20241016)
wcp8 (due 20241016)
fwg1 (due 20241023)
pct9 (bonus; due 20241023)
wcp9 (due 20241023)
fwg2 (due 20241030)
gfo1 (due 20241030)
pctA (due 20241030)
wcpA (due 20241030)
fwg3 (due 20241106)
pctB (bonus; due 20241106)
wcpB (due 20241106)
oop0 (due 20241113)
pctC (due 20241113)
wcpC (due 20241113)
pctD (bonus; due 20241120)
wcpD (bonus; due 20241120)
bwp2 (bonus; due 20241204)
gfo2 (due 20241204)
pctE (bonus; due 20241204)
wcpE (bonus; due 20241204)
EoCE (due 20241216)
haas:fall2024:cprog:projects:cnv0

Corning Community College

CSCS1320 C/C++ Programming

Project: CALCULATING N-ARY VALUES (cnv0)

Objective

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.

GRABIT

To assist with consistency across all implementations, data files for use with this project are available on lab46 via the grabit tool. Be sure to obtain it and ensure your implementation properly works with the provided data.

lab46:~/src/SEMESTER/DESIG$ grabit DESIG PROJECT

Please study any provided code, comments, or supporting documents, and look up, experiment, and ask questions on aspects that you do not understand.

EDIT

You will want to go here to edit and fill in the various sections of the document:

CNV0

Background

Determining factor pairs

Compiling

Loops

for() loops

for() loops are used to repeat a block of code a certain amount of times

for() loops have a fixed format

for(first; second; third){code block}

The first expression is executed once at the start of the statement. The second expression must evaluate to a boolean and is evaluated before every loop. The third expression is executed after every loop.

The following is an example of how a for() loop can be used

for(int i = 10; i >= 0; i--){
    fprintf(stdout, "T minus %d\n", i);
}
fprintf(stdout, "BLAST OFF!\n");
while() loops

while() loops are used to repeat a block of code until a certain condition is no longer met

The format for a while loop is as follows:

while(expression){code block}

The expression within parentheses will run every loop before the code block and is evaluated as a boolean

The code block will run only if the expression within the parentheses evaluates to true

signed int value = 7;
while(value < 1000){
    fprintf(stdout, "value is %d\n", value);
    value = value * 2 + 3;
}

The loop in this code runs 7 times, outputting 7, 17, 37, 77, 157, 317, and 637; stopping before printing 1277

while() loops are best used when the amount of times a block of code is intended to run is not explicit or simple to calculate

do-while loops

do-while loops are used to repeat a block of code until a certain condition is no longer met

The only difference between a do-while loop and a while() loop is that the block of code in a do-while loop is run unconditionally initially

The format of a do-while loop is as follows:

do{code block}
while(expression);

The expression within parentheses will run every loop after the code block and is evaluated as a boolean

The code block will run only again if the expression within the parentheses evaluates to true

signed int value = 0;
do{
    fprintf(stdout, "value is %d\n", value);
    value = value * 2 + 3;
}
while(value > 0 && value < 1000);

This code prints value if it is between 0 and 1000 exclusive. However, value is printed while it is 0 because it was before the while() condition

 

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, displaying its eligibility as a secondary number.

Specifications

Your program should:

  • have valid, descriptive variable names of length no shorter than 4 symbols
  • 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
  • have proximal comments explaining your rationale (the why and how), throughout your code
  • to STDERR, prompt for the number (range appropriate of an unsigned long int)
    • properly store this in a variable of type unsigned long int
  • immediately after the input, check to make sure the input number is a positive number greater than or equal to 2; if in violation, display an error (to STDERR) and exit with a non-zero value.
  • proceed to evaluate the input number, determining whether or not it is a secondary (nary(2)) number.
    • if it is, display to STDOUT that it is a secondary number (see execution section below for message)
    • if it is not, display to STDOUT that it is not a secondary number (again, see execution section below)
  • using a single return statement at the conclusion of the code, return a 0 indicating successful operation

Some additional points of consideration:

  • Note that the driving variables in your loops need to be at least of type short int, otherwise you may get a warning when you compile it.

Process

In general, you will be looking to do something like the following:

DISPLAY PROMPT
READ NUMBER

SHOULD NUMBER BE LOWER THAN TWO:
    DISPLAY AN ERROR
    EXIT WITH A NON-ZERO STATUS

SO LONG AS FACTOR IS LESS THAN NUMBER:
    SHOULD THE FACTOR BE A LEGITIMATE FACTOR OF NUMBER:
        INCREMENT COUNT OF FACTOR PAIRS
        SHOULD THIS NUMBER HAVE A SQUARE FACTOR:
            INCREMENT COUNT OF FACTOR PAIRS

SHOULD THE NUMBER OF FACTOR PAIRS MATCH WHAT WE ARE LOOKING FOR:
    DISPLAY THAT NUMBER BEING PROCESSED IS OF THE NEEDED TYPE
OTHERWISE:
    DISPLAY THAT THE NUMBER BEING PROCESSED IS NOT THE NEEDED TYPE

Reference

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:

yourpi:~/src/SEMESTER/DESIG/cnv0$ make check
Enter a number: 6
6 is a secondary number
yourpi:~/src/SEMESTER/DESIG/cnv0$ 

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. You can run the verify script using the Makefile, as follows:

yourpi:~/src/SEMESTER/DESIG/PROJECT$ make verify
[  1] you have: err, should be: err    [  2] you have:  no, should be:  no
[  3] you have:  no, should be:  no    [  4] you have: yes, should be: yes
[  5] you have:  no, should be:  no    [  6] you have: yes, should be: yes
[  7] you have:  no, should be:  no    [  8] you have: yes, should be: yes
[  9] you have: yes, should be: yes    [ 10] you have: yes, should be: yes
[ 11] you have:  no, should be:  no    [ 12] you have:  no, should be:  no
[ 13] you have:  no, should be:  no    [ 14] you have: yes, should be: yes
[ 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
[ 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
[ 23] you have:  no, should be:  no    [ 24] you have:  no, should be:  no
[ 25] you have: yes, should be: yes    [ 26] you have: yes, should be: yes
[ 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
[ 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
[ 35] you have: yes, should be: yes    [ 36] you have:  no, should be:  no
yourpi:~/src/SEMESTER/DESIG/PROJECT$ 

SUBMISSION

To successfully complete this project, the following criteria must be met:

  • Code must compile cleanly (no notes, warnings, nor errors)
  • Output must be correct, and match the form given in the sample output above.
  • Code must be nicely and consistently indented
  • Code must be well commented
  • Do NOT double space your code. Group like statements together.
  • Output Formatting (including spacing) of program must conform to the provided output (see above).
  • Track/version the source code in a repository
  • Submit a copy of your source code to me using the submit tool.

Submit Tool Usage

To submit this program to me using the submit tool, run the following command at your lab46 prompt:

lab46:~/src/SEMESTER/DESIG/PROJECT$ make submit

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.

RUBRIC

I'll be evaluating the project based on the following criteria:

78:cnv0:final tally of results (78/78)
*:cnv0:resources obtained via grabit by Sunday before deadline [6/6]
*:cnv0:proper error checking and status reporting performed [7/7]
*:cnv0:correct variable types and name lengths used [6/6]
*:cnv0:proper output formatting per specifications [13/13]
*:cnv0:proper selection logic applied to perform comparisions [13/13]
*:cnv0:proper iteration logic applied to carry out process [13/13]
*:cnv0:runtime verify tests of submission succeed [7/7]
*:cnv0:no negative compiler messages for program [7/7]
*:cnv0:code is pushed to lab46 repository [6/6]

Pertaining to the collaborative authoring of project documentation

  • each class member is to participate in the contribution of relevant information and formatting of the documentation
    • minimal member contributions consist of:
      • near the class average edits (a value of at least four productive edits)
      • near the average class content change average (a value of at least 256 bytes (absolute value of data content change))
      • near the class total content contribution average (a value of at least 1kiB)
      • no zero-sum commits: no adding in one commit then later removing in its entirety for the sake of satisfying edit requirements
    • adding and formatting data in an organized fashion, aiming to create an informative and readable document that anyone in the class can reference
    • content contributions will be factored into a documentation coefficient, a value multiplied against your actual project submission to influence the end result:
      • no contributions, co-efficient is 0.50
      • less than minimum contributions is 0.75
      • met minimum contribution threshold is 1.00

Additionally

  • Solutions not abiding by spirit of project will be subject to a 50% overall deduction
  • Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction
  • Solutions not utilizing indentation to promote scope and clarity or otherwise maintaining consistency in code style and presentation will be subject to a 25% overall deduction
  • Solutions not organized and easy to read (assume a terminal at least 90 characters wide, 40 characters tall) are subject to a 25% overall deduction
haas/fall2024/cprog/projects/cnv0.txt · Last modified: 2024/09/09 21:17 by 127.0.0.1