03dc238e239c4d0866d8124e46dd1ae399fb91d4
haas/spring2026/cprog/projects/cit0.md
| ... | ... | @@ -0,0 +1,194 @@ |
| 1 | +# CSCS1320 C/C++ Programming |
|
| 2 | + |
|
| 3 | +# PROJECT: C INTEGER TYPES (cit0) |
|
| 4 | + |
|
| 5 | +## OBJECTIVE |
|
| 6 | + |
|
| 7 | +To begin our exploration of programming, starting with an investigation |
|
| 8 | +into the various integer data types available in C, along with their |
|
| 9 | +properties. |
|
| 10 | + |
|
| 11 | +## GRABIT |
|
| 12 | + |
|
| 13 | +To assist with consistency across all implementations, data files for use |
|
| 14 | +with this project are available on lab46 via the **grabit** tool. Be sure |
|
| 15 | +to obtain it and ensure your implementation properly works with the |
|
| 16 | +provided data. |
|
| 17 | + |
|
| 18 | +``` |
|
| 19 | +lab46:~/src/SEMESTER/cprog$ grabit cprog cit0 |
|
| 20 | +``` |
|
| 21 | + |
|
| 22 | +Please study any provided code or supporting documents, and look up, |
|
| 23 | +experiment, and ask questions on aspects that you do not understand. |
|
| 24 | + |
|
| 25 | +## SCOPE |
|
| 26 | + |
|
| 27 | +This project will be exploring the nature of some of the data types |
|
| 28 | +available to us in the C Programming Language. How much space is |
|
| 29 | +allocated to each type, and what are the ranges available for each type? |
|
| 30 | + |
|
| 31 | +A program is provided that will display (to STDOUT) the size (in bytes), |
|
| 32 | +the lower and upper bounds of each studied type, and some other related |
|
| 33 | +information. |
|
| 34 | + |
|
| 35 | +The data types covered for this project will include **signed** (can be |
|
| 36 | +positive/negative) and **unsigned** (absolute values, no sign) variations |
|
| 37 | +of: |
|
| 38 | + |
|
| 39 | + * `char` |
|
| 40 | + * `short int` |
|
| 41 | + * `int` |
|
| 42 | + * `long int` |
|
| 43 | + * `long long int` |
|
| 44 | + |
|
| 45 | +The **sizeof()** and **fprintf()** functions, as well as arithmetic and |
|
| 46 | +logical operators, will be utilized in performing much of the work. |
|
| 47 | + |
|
| 48 | +## TASK |
|
| 49 | + |
|
| 50 | +Your task is to first study and understand what the provided code is |
|
| 51 | +doing. It is expected you will ask questions on discord to gain |
|
| 52 | +clarification. |
|
| 53 | + |
|
| 54 | +There is extensive commenting in place in the source file for you to |
|
| 55 | +read, which will explain many of the details about each item of |
|
| 56 | +information being obtained. |
|
| 57 | + |
|
| 58 | +Once you have an understanding of what is going on, extend the code to |
|
| 59 | +support the other types (both signed and unsigned). In total, you should |
|
| 60 | +have TEN total sections. |
|
| 61 | + |
|
| 62 | +## HEXADECIMAL |
|
| 63 | + |
|
| 64 | +When dealing with things like addresses and raw data on the computer |
|
| 65 | +(a **binary** device), it is common practice to interact in some |
|
| 66 | +power-of-two base, with base 16 (hexadecimal) being the most common in |
|
| 67 | +use today. |
|
| 68 | + |
|
| 69 | +I would encourage you to memorize and become very familiar with |
|
| 70 | +navigating the following table: |
|
| 71 | + |
|
| 72 | +| base 2 | base 8 | base 10 (unsigned) | base 10 (signed) | base 16 | |
|
| 73 | +| ------ | ------ | ------------------ | ---------------- | ------- | |
|
| 74 | +| `0000` | `000` | `0` | `+0` | `0x0` | |
|
| 75 | +| `0001` | `001` | `1` | `+1` | `0x1` | |
|
| 76 | +| `0010` | `002` | `2` | `+2` | `0x2` | |
|
| 77 | +| `0011` | `003` | `3` | `+3` | `0x3` | |
|
| 78 | +| `0100` | `004` | `4` | `+4` | `0x4` | |
|
| 79 | +| `0101` | `005` | `5` | `+5` | `0x5` | |
|
| 80 | +| `0110` | `006` | `6` | `+6` | `0x6` | |
|
| 81 | +| `0111` | `007` | `7` | `+7` | `0x7` | |
|
| 82 | +| `1000` | `010` | `8` | `-8` | `0x8` | |
|
| 83 | +| `1001` | `011` | `9` | `-7` | `0x9` | |
|
| 84 | +| `1010` | `012` | `10` | `-6` | `0xA` | |
|
| 85 | +| `1011` | `013` | `11` | `-5` | `0xB` | |
|
| 86 | +| `1100` | `014` | `12` | `-4` | `0xC` | |
|
| 87 | +| `1101` | `015` | `13` | `-3` | `0xD` | |
|
| 88 | +| `1110` | `016` | `14` | `-2` | `0xE` | |
|
| 89 | +| `1111` | `017` | `15` | `-1` | `0xF` | |
|
| 90 | + |
|
| 91 | +It might be worthwhile to ask questions about the nature of the values on |
|
| 92 | +this table on the class discord, to gain a better understanding of why |
|
| 93 | +these values are here, how they were derived, and what value they bring |
|
| 94 | +to our interaction with computers. |
|
| 95 | + |
|
| 96 | +## COMPILING |
|
| 97 | + |
|
| 98 | +The compilation process for working with your source code is as follows: |
|
| 99 | + |
|
| 100 | +``` |
|
| 101 | +lab46:~/src/SEMESTER/cprog/cit0$ gcc -Wall --std=gnu18 -o cit0 cit0.c |
|
| 102 | +lab46:~/src/SEMESTER/cprog/cit0$ |
|
| 103 | +``` |
|
| 104 | + |
|
| 105 | +Assuming there are no syntax errors or warnings, and everything compiled |
|
| 106 | +correctly, you should just get your prompt back. In the event of |
|
| 107 | +problems, the compiler will be sure to tell you about them. |
|
| 108 | + |
|
| 109 | +Conceptually, the arrangement is as follows: |
|
| 110 | + |
|
| 111 | +``` |
|
| 112 | +gcc -Wall --std=gnu18 -o BINARYFILE SOURCEFILE |
|
| 113 | +``` |
|
| 114 | + |
|
| 115 | +The `BINARYFILE` comes **immediately after** the **-o**, **NOT** the |
|
| 116 | +`SOURCEFILE` (the source file must never **immediately** follow a |
|
| 117 | +**-o**). It can precede, and such is perfectly valid (especially if you |
|
| 118 | +feel that way more intuitive). |
|
| 119 | + |
|
| 120 | +The `-Wall` (treat all warnings as errors, increase general verbosity |
|
| 121 | +about warnings) and `--std=gnu18` (switch compiler to use a newer |
|
| 122 | +standard of the C language, with GNU extensions) are options given to the |
|
| 123 | +compiler. |
|
| 124 | + |
|
| 125 | +## EXECUTION |
|
| 126 | + |
|
| 127 | +To execute your binary, we need to specify a path to it, so we use |
|
| 128 | +**./**, which basically references the current directory: |
|
| 129 | + |
|
| 130 | +``` |
|
| 131 | +lab46:~/src/SEMESTER/cprog/cit0$ ./cit0 |
|
| 132 | +signed char |
|
| 133 | +========================================= |
|
| 134 | +total size in bytes: 1 |
|
| 135 | +total size in bits: 8 |
|
| 136 | +value contains: 17 |
|
| 137 | +value exists in memory at: 0x7ffc1a16d967 |
|
| 138 | +minimum value represented: -128 |
|
| 139 | +maximum value represented: 127 |
|
| 140 | +possible distinct values: 256 |
|
| 141 | +========================================= |
|
| 142 | +``` |
|
| 143 | + |
|
| 144 | +Your completed program will have far more output: additional sections |
|
| 145 | +each representing one of the integer type combinations (a total of 10). |
|
| 146 | + |
|
| 147 | +## SUBMISSION |
|
| 148 | + |
|
| 149 | +To successfully complete this project, the following criteria must be |
|
| 150 | +met: |
|
| 151 | + |
|
| 152 | + * Code must compile/execute cleanly (no notes, warnings, nor errors) |
|
| 153 | + * Code must be nicely and consistently indented |
|
| 154 | + * Code must be well commented |
|
| 155 | + * Do NOT double space your code. Group like statements together. |
|
| 156 | + * Track/version the source code in your private semester repository |
|
| 157 | + * Submit a copy of your source code to me using the **submit** tool |
|
| 158 | + |
|
| 159 | +To submit this program to me using the **submit** tool, run the following |
|
| 160 | +command at your LAB46 prompt: |
|
| 161 | + |
|
| 162 | +``` |
|
| 163 | +lab46:~/src/SEMESTER/cprog/cit0$ make submit |
|
| 164 | +``` |
|
| 165 | + |
|
| 166 | +You should get some sort of confirmation indicating successful submission |
|
| 167 | +if all went according to plan. If not, check for typos and or locational |
|
| 168 | +mismatches. |
|
| 169 | + |
|
| 170 | +What I'll be looking for: |
|
| 171 | + |
|
| 172 | +### RUBRIC |
|
| 173 | + |
|
| 174 | +I'll be evaluating the project based on the following criteria: |
|
| 175 | + |
|
| 176 | +``` |
|
| 177 | +104:cit0:final tally of results (104/104) |
|
| 178 | +*:cit0:grabit the code on lab46 by Sunday before deadline [13/13] |
|
| 179 | +*:cit0:code is pushed to private semester repository [13/13] |
|
| 180 | +*:cit0:proper output formatting per specifications [13/13] |
|
| 181 | +*:cit0:clean compile, no compiler messages [13/13] |
|
| 182 | +*:cit0:each integer type explored in full [26/26] |
|
| 183 | +*:cit0:program conforms to project specifications [26/26] |
|
| 184 | +``` |
|
| 185 | + |
|
| 186 | +NOTE: spirit of the project includes using hexadecimal values and bitwise |
|
| 187 | +logic operators to set the pertinent upper/lower bounds. |
|
| 188 | + |
|
| 189 | +Additionally: |
|
| 190 | + * Solutions not abiding by spirit of project will be subject to a 50% overall deduction |
|
| 191 | + * Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction |
|
| 192 | + * 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 |
|
| 193 | + * 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 |
|
| 194 | + |
haas/spring2026/cprog/projects/sof0.md
| ... | ... | @@ -0,0 +1,374 @@ |
| 1 | +# CSCS1320 C/C++ Programming |
|
| 2 | + |
|
| 3 | +# PROJECT: SQUARES OF FIVE (sof0) |
|
| 4 | + |
|
| 5 | +## OBJECTIVE |
|
| 6 | + |
|
| 7 | +To implement a programmatic solution (ie simulation) of a real life |
|
| 8 | +process: the mental math trick of computing the square of any number |
|
| 9 | +ending with 5. |
|
| 10 | + |
|
| 11 | +The allure of using (and learning) a programming language is to be able |
|
| 12 | +to effectively use it to solve problems, which in and of themselves are |
|
| 13 | +simulations of some process we can do in "the real world". |
|
| 14 | + |
|
| 15 | +In this case, we will be writing a program which will implement the |
|
| 16 | +mental math techniques for computing the square of any one, two-, or |
|
| 17 | +three-digit number that ends with 5. |
|
| 18 | + |
|
| 19 | +There are other (perhaps more direct) means of performing this task, but |
|
| 20 | +that is not the objective here: you are to implement your solution |
|
| 21 | +adhering to the process described herein, which will expose you to |
|
| 22 | +important programmatic and problem solving details. |
|
| 23 | + |
|
| 24 | +## BACKGROUND |
|
| 25 | + |
|
| 26 | +Mental Math constitutes an intersection of mental techniques and math- |
|
| 27 | +instead of utilizing a purely math-only solution, textual manipulations |
|
| 28 | +or simplifications in the computational process may take place enabling |
|
| 29 | +an individual to, once having learned the process, solve such problems in |
|
| 30 | +their head, and typically without the use of a calculating device. |
|
| 31 | + |
|
| 32 | +The process in this case is one of numeric manipulation and simple |
|
| 33 | +(reduced) multiplication. To wit: |
|
| 34 | + |
|
| 35 | +### SQUARING A VALUE |
|
| 36 | + |
|
| 37 | +Squaring is essentially multiplying a number by itself- |
|
| 38 | + |
|
| 39 | + * `5` squared is `5*5` or `25` |
|
| 40 | + * `8` squared is `8*8` or `64` |
|
| 41 | + |
|
| 42 | +While not outwardly a difficult procedure, the nature of multiplying |
|
| 43 | +multiple digit numbers in your head can quickly result in more steps (and |
|
| 44 | +more steps means more time, if doing things the traditional way). |
|
| 45 | + |
|
| 46 | +Finding a shortcut through this process enables it to remain solidly |
|
| 47 | +within the realm of mental math, and makes for a good algorithm to |
|
| 48 | +practice implementing on the computer. |
|
| 49 | + |
|
| 50 | +This particular trick relies on a subset of the squares: those ending |
|
| 51 | +with a 5 (a five in the ones place). |
|
| 52 | + |
|
| 53 | +The implementational scope of this trick will be just values of one-, |
|
| 54 | +two-, and three-digits ending with 5: |
|
| 55 | + |
|
| 56 | + * 5 |
|
| 57 | + * 15 |
|
| 58 | + * 25 |
|
| 59 | + * 35 |
|
| 60 | + * 45 |
|
| 61 | + * 55 |
|
| 62 | + * 65 |
|
| 63 | + * 75 |
|
| 64 | + * 85 |
|
| 65 | + * 95 |
|
| 66 | + * 105 |
|
| 67 | + * 115 |
|
| 68 | + * 125 |
|
| 69 | + * ... |
|
| 70 | + * 235 |
|
| 71 | + * 245 |
|
| 72 | + * ... |
|
| 73 | + * 485 |
|
| 74 | + * 495 |
|
| 75 | + * 505 |
|
| 76 | + * ... |
|
| 77 | + * 995 |
|
| 78 | + |
|
| 79 | +### SQUARING VALUES ENDING WITH 5 |
|
| 80 | + |
|
| 81 | +The trick here is two-fold. First, we separate the one's place 5 from the |
|
| 82 | +rest of the number (which can be accomplished in our mind's easily |
|
| 83 | +enough, but on the computer we must resort to some math). |
|
| 84 | + |
|
| 85 | +We then take that isolated five and square it; we'll get 25. That is how |
|
| 86 | +our result will end (so bam! we now have our tens and ones place already |
|
| 87 | +solved) |
|
| 88 | + |
|
| 89 | +Next, we take the remaining digits of the original value, and multiply it |
|
| 90 | +by its increment: |
|
| 91 | + |
|
| 92 | + * 1's increment (1+1) is 2, so `1*2` |
|
| 93 | + * 2's increment (2+1) is 3, so `2*3` |
|
| 94 | + * 3's increment (3+1) is 4, so `3*4` |
|
| 95 | + * 4's increment (4+1) is 5, so `4*5` |
|
| 96 | + * ... |
|
| 97 | + * 9's increment (9+1) is 10, so `9*10` |
|
| 98 | + |
|
| 99 | +We take this result and append the 25 after it. |
|
| 100 | + |
|
| 101 | +For example: |
|
| 102 | + |
|
| 103 | +``` |
|
| 104 | +15 * 15 = 1*(1+1) 5*5 |
|
| 105 | + = 1*2 5*5 |
|
| 106 | + = 2 25 |
|
| 107 | + = 225 |
|
| 108 | +``` |
|
| 109 | + |
|
| 110 | +... and ... |
|
| 111 | + |
|
| 112 | +``` |
|
| 113 | +75 * 75 = 7*(7+1) 5*5 |
|
| 114 | + = 7*8 5*5 |
|
| 115 | + = 56 25 |
|
| 116 | + = 5625 |
|
| 117 | +``` |
|
| 118 | + |
|
| 119 | +For a single digit number like 5, when you take the 5 away, what do you |
|
| 120 | +get? **ZERO**. Zero times anything is zero, so the result is 0 25, or 25 |
|
| 121 | +(ie this process still works). |
|
| 122 | + |
|
| 123 | +For three digit numbers like 105, we have 10, and its increment is 11, so |
|
| 124 | +10 x 11 = 110. |
|
| 125 | + |
|
| 126 | +``` |
|
| 127 | +105 * 105 = 10*(10+1) 5*5 |
|
| 128 | + = 10*11 5*5 |
|
| 129 | + = 110 25 |
|
| 130 | + = 11025 |
|
| 131 | +``` |
|
| 132 | + |
|
| 133 | +## GRABIT |
|
| 134 | + |
|
| 135 | +I have prepared a `grabit` for resources related to this project. To |
|
| 136 | +obtain it: |
|
| 137 | + |
|
| 138 | +``` |
|
| 139 | +lab46:~/src/SEMESTER/DESIG$ grabit DESIG sof0 |
|
| 140 | +make: Entering directory '/var/public/SEMESTER/DESIG/sof0' |
|
| 141 | +'/var/public/SEMESTER/DESIG/sof0/Makefile' -> '/home/user/src/SEMESTER/DESIG/sof0/Makefile' |
|
| 142 | +'/var/public/SEMESTER/DESIG/sof0/sof0.c' -> '/home/user/src/SEMESTER/DESIG/sof0/sof0.c' |
|
| 143 | +make: Leaving directory '/var/public/SEMESTER/DESIG/sof0' |
|
| 144 | +lab46:~/src/SEMESTER/DESIG$ |
|
| 145 | +``` |
|
| 146 | + |
|
| 147 | +At which point you can change into the newly created and populated |
|
| 148 | +`sof0` directory. |
|
| 149 | + |
|
| 150 | +Be sure to **add**, **commit**, and **push** this to your lab46 clone of |
|
| 151 | +your repository. |
|
| 152 | + |
|
| 153 | +Then, if working on your pi/system, **pull** and **update** to get the |
|
| 154 | +files available there, or continue working on it on lab46. |
|
| 155 | + |
|
| 156 | +## PROGRAM |
|
| 157 | + |
|
| 158 | +It is your task to write the program that will use the above method to |
|
| 159 | +compute the square of the input value ending with a 5 (you are to input |
|
| 160 | +the entire number, including the 5 at the end). |
|
| 161 | + |
|
| 162 | +Your program should: |
|
| 163 | + * prompt the user for the number (input) |
|
| 164 | + * input number as an unsigned short integer |
|
| 165 | + * perform the task (process) |
|
| 166 | + * isolate one's digit mathematically, store in a variable (unsigned short int) |
|
| 167 | + * isolate remaining digits mathematically, store in another variable (unsigned short int) |
|
| 168 | + * perform the algorithm on the two pieces, storing their results in two separate variables (of type unsigned short int) |
|
| 169 | + * display the final value (output) |
|
| 170 | + * display the beginning and ending parts together (but stored in separate variables) |
|
| 171 | + * display the resulting number to STDOUT (right-justified in a space supporting the largest possible value -- see output example below) |
|
| 172 | + * display any supporting text to STDERR (display of source values left-justified in a space supporting 3-digit values -- see output example below). |
|
| 173 | + * because we have not officially learned how to do selection/have the computer react to conditions, please implement with the assumption that the user will ALWAYS input a correct value. Do not worry about having to check for invalid or illegal input values (I will not be checking for such when I evaluate your project). |
|
| 174 | + |
|
| 175 | +## COMPILING |
|
| 176 | + |
|
| 177 | +The compilation process for working with your source code is as follows: |
|
| 178 | + |
|
| 179 | +``` |
|
| 180 | +lab46:~/src/SEMESTER/cprog/sof0$ gcc -Wall --std=gnu18 -o sof0 sof0.c |
|
| 181 | +lab46:~/src/SEMESTER/cprog/sof0$ |
|
| 182 | +``` |
|
| 183 | + |
|
| 184 | +Assuming there are no syntax errors or warnings, and everything compiled |
|
| 185 | +correctly, you should just get your prompt back. In the event of |
|
| 186 | +problems, the compiler will be sure to tell you about them. |
|
| 187 | + |
|
| 188 | +Conceptually, the arrangement is as follows: |
|
| 189 | + |
|
| 190 | +``` |
|
| 191 | +gcc -Wall --std=gnu18 -o BINARYFILE SOURCEFILE |
|
| 192 | +``` |
|
| 193 | + |
|
| 194 | +The `BINARYFILE` comes **immediately after** the **-o**, **NOT** the |
|
| 195 | +`SOURCEFILE` (the source file must never **immediately** follow a |
|
| 196 | +**-o**). It can precede, and such is perfectly valid (especially if you |
|
| 197 | +feel that way more intuitive). |
|
| 198 | + |
|
| 199 | +The `-Wall` (treat all warnings as errors, increase general verbosity |
|
| 200 | +about warnings) and `--std=gnu18` (switch compiler to use a newer |
|
| 201 | +standard of the C language, with GNU extensions) are options given to the |
|
| 202 | +compiler. |
|
| 203 | + |
|
| 204 | +## EXECUTION |
|
| 205 | + |
|
| 206 | +To execute your binary, we need to specify a path to it, so we use |
|
| 207 | +**./**, which basically references the current directory: |
|
| 208 | + |
|
| 209 | +``` |
|
| 210 | +lab46:~/src/SEMESTER/cprog/sof0$ ./sof0 |
|
| 211 | +Enter value: 75 |
|
| 212 | +75 x 75 = 5625 |
|
| 213 | +lab46:~/src/SEMESTER/cprog/sof0$ |
|
| 214 | +``` |
|
| 215 | + |
|
| 216 | +The execution of the program is short and simple- obtain the input, do |
|
| 217 | +the processing, produce the output, and then terminate. |
|
| 218 | + |
|
| 219 | +Note how the two "75" values are left-justified within a 3-space slot |
|
| 220 | +(with the multiplication 'x' and equal sign '=' being padded with a space |
|
| 221 | +on either side). This information should all be displayed to STDERR. |
|
| 222 | + |
|
| 223 | +Similarly, here's an example of 105x105: |
|
| 224 | + |
|
| 225 | +``` |
|
| 226 | +lab46:~/src/SEMESTER/cprog/sof0$ ./sof0 |
|
| 227 | +Enter value: 105 |
|
| 228 | +105 x 105 = 11025 |
|
| 229 | +lab46:~/src/SEMESTER/cprog/sof0$ |
|
| 230 | +``` |
|
| 231 | + |
|
| 232 | +The 'x' and '=' padding persists, but because we're squaring a 3-digit |
|
| 233 | +value vs. a 2-digit value, we occupy the entire allocated space on the |
|
| 234 | +screen. |
|
| 235 | + |
|
| 236 | +If you'd like to verify successful output to STDOUT/STDERR, you can |
|
| 237 | +perform the following tests. First, verify that the answer (and ONLY the |
|
| 238 | +answer), is being sent to STDOUT -- we do this by eliminating STDERR |
|
| 239 | +entirely: |
|
| 240 | + |
|
| 241 | +``` |
|
| 242 | +lab46:~/src/SEMESTER/cprog/sof0$ ./sof0 2> /dev/null <<< 105 |
|
| 243 | + 11025 |
|
| 244 | +lab46:~/src/SEMESTER/cprog/sof0$ |
|
| 245 | +``` |
|
| 246 | + |
|
| 247 | +What we are doing here is two-fold: |
|
| 248 | + |
|
| 249 | + * We are using command-line I/O redirection to redirect STDERR (which is bound to file descriptor #2) to the system bit-bucket. |
|
| 250 | + * We are "redirecting" STDIN using a **here string**, providing the program's input of **105** right on the command-line at time of execution. |
|
| 251 | + |
|
| 252 | +Similarly, if we were to eliminate STDOUT entirely (for verifying STDERR |
|
| 253 | +output): |
|
| 254 | + |
|
| 255 | +``` |
|
| 256 | +lab46:~/src/SEMESTER/cprog/sof0$ ./sof0 1> /dev/null |
|
| 257 | +Enter value: 75 |
|
| 258 | +75 x 75 = lab46:~/src/SEMESTER/cprog/sof0$ |
|
| 259 | +``` |
|
| 260 | + |
|
| 261 | +What we are doing here: |
|
| 262 | + |
|
| 263 | + * We are using command-line I/O redirection to redirect STDOUT (which is bound to file descriptor #1) to the system bit-bucket. |
|
| 264 | + |
|
| 265 | +## VERIFICATION |
|
| 266 | + |
|
| 267 | +One of the tests I will perform for output compliance of your code will |
|
| 268 | +involve comparing your program's output against a range of input values, |
|
| 269 | +to see if they all output in conformance with project specifications. |
|
| 270 | + |
|
| 271 | +I will make use of a checksum to verify exactness. |
|
| 272 | + |
|
| 273 | +You will need to run this from your sof0 project directory with a |
|
| 274 | +compiled and operational binary by the name of **sof0**. |
|
| 275 | + |
|
| 276 | +You can check your project by typing in the following at the prompt: |
|
| 277 | + |
|
| 278 | +``` |
|
| 279 | +lab46:~/src/SEMESTER/cprog/sof0$ pchk cprog sof0 |
|
| 280 | +``` |
|
| 281 | + |
|
| 282 | +If all aligns, you will see this: |
|
| 283 | + |
|
| 284 | +``` |
|
| 285 | +================================================== |
|
| 286 | += CPROG sof0 project output validation tool = |
|
| 287 | +================================================== |
|
| 288 | +sof0 checksum is: 822a47fb2a45845500b6c10878045bd5 |
|
| 289 | +your checksum is: 822a47fb2a45845500b6c10878045bd5 |
|
| 290 | +================================================== |
|
| 291 | + verification: SUCCESS! |
|
| 292 | +================================================== |
|
| 293 | +``` |
|
| 294 | + |
|
| 295 | +If something is off, your checksum will not match the sof0 checksum, and |
|
| 296 | +verification will instead say "**MISMATCH**", like follows (note that a |
|
| 297 | +mismatched checksum can be anything, and likely not what is seen in this |
|
| 298 | +example): |
|
| 299 | + |
|
| 300 | +``` |
|
| 301 | +================================================== |
|
| 302 | += CPROG sof0 project output validation tool = |
|
| 303 | +================================================== |
|
| 304 | +sof0 checksum is: 822a47fb2a45845500b6c10878045bd5 |
|
| 305 | +your checksum is: 92af264c86823a61529948caaeac53e0 |
|
| 306 | +================================================== |
|
| 307 | + verification: MISMATCH |
|
| 308 | +================================================== |
|
| 309 | +``` |
|
| 310 | + |
|
| 311 | +## QUESTIONS FOR CONSIDERATION |
|
| 312 | + |
|
| 313 | +These are things I'd like you to contemplate, even use as potential |
|
| 314 | +material on your weekly journal entry. The more you think about and |
|
| 315 | +understand the problem, the better your ability to solve it and other |
|
| 316 | +problems. |
|
| 317 | + |
|
| 318 | + * Why/how does this trick work for 1-digit numbers? |
|
| 319 | + * Considering our 1-, 2-, and 3-digit domain restriction for this project, how many candidate values are there for input? |
|
| 320 | + * What is the smallest input value? |
|
| 321 | + * What is the largest input value? |
|
| 322 | + * How many input values are there that end in **5**? |
|
| 323 | + * What is the largest square that can be calculated given the project input restrictions? |
|
| 324 | + * How many digits is the largest square? |
|
| 325 | + * How can knowing how many digits the largest square is help you implement your solution? |
|
| 326 | + |
|
| 327 | +## SUBMISSION |
|
| 328 | + |
|
| 329 | +To successfully complete this project, the following criteria must be |
|
| 330 | +met: |
|
| 331 | + |
|
| 332 | + * Code must compile/execute cleanly (no notes, warnings, nor errors) |
|
| 333 | + * Code must be nicely and consistently indented |
|
| 334 | + * Code must be well commented |
|
| 335 | + * Do NOT double space your code. Group like statements together. |
|
| 336 | + * Track/version the source code in your private semester repository |
|
| 337 | + * Submit a copy of your source code to me using the **submit** tool |
|
| 338 | + |
|
| 339 | +To submit this program to me using the **submit** tool, run the following |
|
| 340 | +command at your LAB46 prompt: |
|
| 341 | + |
|
| 342 | +``` |
|
| 343 | +lab46:~/src/SEMESTER/cprog/sof0$ make submit |
|
| 344 | +``` |
|
| 345 | + |
|
| 346 | +You should get some sort of confirmation indicating successful submission |
|
| 347 | +if all went according to plan. If not, check for typos and or locational |
|
| 348 | +mismatches. |
|
| 349 | + |
|
| 350 | +What I'll be looking for: |
|
| 351 | + |
|
| 352 | +### RUBRIC |
|
| 353 | + |
|
| 354 | +I'll be evaluating the project based on the following criteria: |
|
| 355 | + |
|
| 356 | +``` |
|
| 357 | +130:sof0:final tally of results (130/130) |
|
| 358 | +*:sof0:grabit the code on lab46 by Sunday before deadline [13/13] |
|
| 359 | +*:sof0:code is pushed to private semester repository [13/13] |
|
| 360 | +*:sof0:proper output formatting per specifications [26/26] |
|
| 361 | +*:sof0:clean compile, no compiler messages [26/26] |
|
| 362 | +*:sof0:program conforms to project specifications [26/26] |
|
| 363 | +*:sof0:progrm passes verification checks [26/26] |
|
| 364 | +``` |
|
| 365 | + |
|
| 366 | +NOTE: The spirit of program implementation includes your process |
|
| 367 | +using the mental math approach, not a more seemingly-straightforward |
|
| 368 | +computational approach, or one given to you out of context by AI. |
|
| 369 | + |
|
| 370 | +Additionally: |
|
| 371 | + * Solutions not abiding by spirit of project will be subject to a 50% overall deduction |
|
| 372 | + * Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction |
|
| 373 | + * Solutions not utilizing indentation to promote scope and clarity will be subject to a 25% overall deduction |
|
| 374 | + * Solutions not organized and easy to read are subject to a 25% overall deduction |