This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
haas:spring2015:cprog:projects:mbe1 [2015/02/06 15:43] – created wedge | haas:spring2015:cprog:projects:mbe1 [2015/02/07 13:31] (current) – wedge | ||
---|---|---|---|
Line 6: | Line 6: | ||
~~TOC~~ | ~~TOC~~ | ||
- | ======Project: | + | ======Project: |
=====Objective===== | =====Objective===== | ||
- | To implement a programmatic solution (ie simulation) of a real life process- the mental math trick of multiplying any one-, two-, or three-digit number by eleven. | + | To implement a programmatic solution (ie simulation) of a real life process- the mental math trick of multiplying any one- through eight-digit number by eleven. |
=====Prerequisites/ | =====Prerequisites/ | ||
In addition to the new skills required on previous projects, to successfully accomplish/ | In addition to the new skills required on previous projects, to successfully accomplish/ | ||
- | * ability | + | * can perform this multiply by 11 trick in your head/by hand (if you can't do it on your own, you have no business trying |
- | * ability | + | * understand the pattern/ |
- | * some may have experience, others may have had it suggested as a means of solving the problem " | + | * ability to deploy |
+ | * ability | ||
=====Scope===== | =====Scope===== | ||
The allure of using (and learning) a programming language is to be able to effectively use it to solve problems, which in and of themselves are simulations of some process we can do in "the real world" | The allure of using (and learning) a programming language is to be able to effectively use it to solve problems, which in and of themselves are simulations of some process we can do in "the real world" | ||
- | In this case, we will be writing a program which will implement the mental math techniques for multiplying any one-, two-, or three-digit number by eleven. | + | In this case, we will be writing a program which will implement the mental math techniques for multiplying any one- through eight-digit number by eleven. |
=====Background===== | =====Background===== | ||
- | Mental Math constitutes an intersection | + | In the **mbe0** project, we commenced our exploration |
- | The process | + | We explored single digit additions, a nostalgic throwback to 2nd/3rd/4th grade math, where we learned how any addition results in a one-digit sum as well as a one-digit carry. |
- | ====Multiplying any single digit number | + | It is hoped that by accomplishing **mbe0**, |
- | This may be a pattern of which you are already aware- | + | |
- | In the case of 1 x 11, we get: 11 | + | I am referring to **loops** and **arrays** |
- | For 2 x 11, we see: 22 | + | ====loops==== |
+ | A loop is basically instructing the computer to repeat a section, or block, or code a given amount of times (it can be based on a fixed value-- repeat this 4 times, or be based on a conditional value-- keep repeating as long as (or while) this value is not 4). | ||
- | For 3 x 11, we have: 33 | + | Loops enable us to simplify our code-- allowing us to write a one-size-fits all algorithm (provided the algorithm itself can appropriately scale!), where the computer merely repeats the instructions |
- | and this trick works all the way through 9 x 11, yielding: 99 | + | Loops can be initially difficult to comprehend because unlike other programmatic actions, they are not single-state in nature-- loops are multi-state. What this means is that in order to correctly " |
- | ====Multiplying any double digit number by 11==== | + | With that said, it is important to be able to focus on the process of the individual steps being taken. What is involved in taking |
- | Here we do a pivot and then perform simple arithmetic to obtain | + | |
- | In the case of 10 x 11, we take 10 and pivot it, getting 1 and 0, respectively our first and last digit of our soon-to-be solution. | + | In C and C-derived languages, we typically have 3 loops: |
- | To get the middle value, we add these two values together: 1+0=1 | + | * for loop (automatic counter loop, stepping loop) - when we know exactly how many times we wish something to run; we know where we want to start, where we want to end, and exactly how to progress from start to end (step value) |
+ | * while loop (top-driven conditional loop) - when we want to repeat a process, but the exact number of iterations is either not known, or not important. While loops can run 0 or more times. | ||
+ | * do-while loop (bottom-driven conditional loop) - similar to the while loop, only we do the check for loop termination at the bottom of the loop, meaning it runs 1 or more times (a do-while loop is guaranteed to run at least once). | ||
- | So, the result | + | ===for loops=== |
- | or: 110 | + | A for loop is the most syntactically unique |
- | Let's try it with 32 x 11: | + | With any loop, we need (at least one) looping variable, which the loop will use to analyze whether or not we've met our looping destination, |
- | < | + | A for loop typically also has a defined starting point, a " |
- | 32 x 11 = 3 (3+2) 2 | + | |
- | = 3 5 2 | + | Here's a sample for loop, in C, which will display the squares of each number, starting at 0, and stepping one at a time, for 8 total iterations: |
- | = 352 | + | |
+ | < | ||
+ | int i = 0; | ||
+ | |||
+ | for (i = 0; i < 8; i++) | ||
+ | { | ||
+ | | ||
+ | } | ||
</ | </ | ||
- | This is almost the entire process, but there' | + | The output of this code, with the help of our loop should be: |
- | For example, let us take the maximum two digit value (99): | + | < |
+ | loop #1 ... 0 | ||
+ | loop #2 ... 1 | ||
+ | loop #3 ... 4 | ||
+ | loop #4 ... 9 | ||
+ | loop #5 ... 16 | ||
+ | loop #6 ... 25 | ||
+ | loop #7 ... 36 | ||
+ | loop #8 ... 49 | ||
+ | </ | ||
- | Using this process as it has been described thus far, we would (incorrectly) get: | + | Note how we can use our looping variable |
- | < | + | And again, we shouldn' |
- | 99 x 11 = 9 (9 + 9) 9 | + | |
- | = 9 18 9 | + | The loop exits once **i** reaches a value of 8, because our loop determinant condition states as long as **i** is **less than** **8**, continue to loop. Once **i** becomes **8**, our looping condition has been satisfied, and the loop will no longer iterate. |
- | = 9189 | + | |
+ | The stepping (that third) field is a mathematical expression indicating how we wish for **i** to progress from its starting state (of being equal to 0) to satisfying the loop's iterating condition (no longer being less than 8). | ||
+ | |||
+ | **i++** is a shortcut we can use in C; the longhand (and likely more familiar) equivalent is: **i = i + 1** | ||
+ | |||
+ | ===while loops=== | ||
+ | A while loop isn't as specific about starting and stepping values, really only caring about what condition needs to be met in order to exit the loop (keep looping while this condition is true). | ||
+ | |||
+ | In actuality, anything we use a for loop for can be expressed as a while loop-- we merely have to ensure we provide the necessary loop variables and progressions within the loop. | ||
+ | |||
+ | That same loop above, expressed as a while loop, could look like: | ||
+ | |||
+ | < | ||
+ | int i = 0; | ||
+ | |||
+ | while (i < 8) | ||
+ | { | ||
+ | fprintf(stdout, | ||
+ | | ||
+ | } | ||
</ | </ | ||
- | But that would be incorrect mathematically. | + | The output of this code should |
- | To compensate (or, to present the full rules for the trick), we take the sum of this result as the middle digit, and apply the carry to the next digit to the left, so: | + | While loops, like for loops, will run 0 or more times; if the conditions enabling |
- | <code> | + | It is possible to introduce a certain kind of **logical error** into your programs using loops-- what is known as an " |
- | 99 x 11 = 9 (9+9) 9 | + | |
- | | + | Another common **logical error** that loops will allow us to encounter will be the "off by one" error-- where the conditions we pose to the loop are incorrect, and the loop runs one more or one less time than we had planned. Again, proper debugging of our code will resolve this situation. |
- | = 10 8 9 | + | |
- | = 1089 | + | ===do-while loops=== |
+ | The third commonly recognized looping structure in C, the do-while loop is identical to the while (and therefore the for) loop, only it differs in where it checks the looping condition: where **for** and **while** are " | ||
+ | |||
+ | The placement of this test determines the minimal number of times a loop can run. | ||
+ | |||
+ | In the case of the for/while loops, because the test is at the top- if the looping conditions are not met, the loop may not run at all. It is for this reason why these loops can run "0 or more times" | ||
+ | |||
+ | For the do-while loop, because the test occurs at the bottom, the body of the loop (one full iteration) is run before the test is encountered. So even if the conditions for looping are not met, a do-while will run "1 or more times" | ||
+ | |||
+ | That may seem like a minor, and possibly annoying, difference, but in nuanced algorithm design, such distinctions can drastically change the layout of your code, potentially being the difference between beautifully elegant-looking solutions and slightly more hackish. They can BOTH be used to solve the same problems, it is merely the nature of how we choose express the solution that should make one more preferable over the other in any given moment. | ||
+ | |||
+ | I encourage you to intentionally try your hand at converting your loops between for/ | ||
+ | |||
+ | So, expressing that same program in the form of a do-while loop (note the changes from the while): | ||
+ | |||
+ | <code c> | ||
+ | int i = 0; | ||
+ | |||
+ | do { | ||
+ | fprintf(stdout, | ||
+ | | ||
+ | } while(i < 8); | ||
</ | </ | ||
- | And we now have the correct result. | + | In this case, the 0 or more vs. 1 or more minimal iterations wasn't important; the difference is purely syntactical. |
- | As another example, let us look at 47 x 11: | + | With the do-while loop, we start the loop with a **do** statement (feel free to put the opening brace on the next line as we have all along-- I'm also demonstrating another style of brace placement). |
- | < | + | Also, the do-while is the only one of our loops which NEEDS a terminating semi-colon (**;**).. please take note of this. |
- | 47 x 11 = 4 (4+7) 7 | + | |
- | | + | ====arrays==== |
- | = 5 | + | The other important component of our **mbe1** project will involve the effective use of arrays to further aid us in having an efficient |
- | = 517 | + | |
+ | An array is basically just a collection of variables. Where before we'd declare a separate variable for each number we'd wish to store, an array lets us have but one variable name, but multiple storage location | ||
+ | |||
+ | An array is what is known as a **homogeneous** composite data type. It technically is a modifier (or adjective, if you will) of any valid variable data type. We basically use it to say " | ||
+ | |||
+ | **homogeneous** means all of the same, indicating it can ONLY contain variables of the exact same type (such as only **int**egers, | ||
+ | |||
+ | An array has a few other requirements: | ||
+ | |||
+ | * its size, once declared, remains constant (you cannot say you'd like a 4 element array and then later ask to double or halve it--- there is no such thing as " | ||
+ | * arrays are located by their name (just as any variable is), along with an address/ | ||
+ | * arrays start at an offset of 0. | ||
+ | * arrays can be expressed as a pointer (I tend to treat them as pointers), and there' | ||
+ | * C cannot perform global operations on arrays-- you must transact on an array one element at a time (this is the case with all languages, although some will cheat and do the work behind-the-scenes, | ||
+ | |||
+ | ===Declaring a 4 element integer array=== | ||
+ | Let us see our array in action: | ||
+ | |||
+ | <code c> | ||
+ | int numbers[4]; | ||
</ | </ | ||
- | Got it? Try it with some other examples. | + | This code will declare a new variable, of type **int**, called **numbers**... the brackets indicate we are allocating **four** consecutive **int**-sized units that will be associated |
- | ===sum vs. carry=== | + | To access the first box, we access the **0** offset; the second box is right next to the first, at offset **1** (it is one int away from the first one). Similar with the third and fourth. |
- | In grade school, when learning to do arithmetic by hand (you still are taught how to do arithmetic by hand, right?), we first learned | + | |
- | Little did you know then, but you were learning | + | To place a **17** in the first (position **0**) element |
- | For example, in the case of the number 18, when dissecting the number into its place values, we have: | + | <code c> |
+ | numbers[0] = 17; | ||
+ | </ | ||
- | | + | To place a **36** in the third (position **2**) element of our **numbers** array, we'd say: |
- | | + | |
- | In single digit terminology, | + | <code c> |
+ | numbers[2] = 36; | ||
+ | </ | ||
- | < | + | ===Using variables as our array index position=== |
- | | + | Because the array index is a number, and things like **int**s are numbers, we can also specify the array location via a variable. To wit, we will assign a 52 to the fourth array element, but do so via an **index** variable we set up: |
- | 9 | + | |
- | + 9 | + | <code c> |
- | ---- | + | int index = 3; |
- | 8 <-- sum (of 1s position) | + | numbers[index] = 52; |
</ | </ | ||
- | See what is happening here? The basis for adding multiple-digit numbers. Perhaps it would make more sense if we showed how adding 9 + 9 was in fact adding two 2-digit numbers together: | + | Because **index** contains a 3, we're telling the computer we wish to put a 52 in the array element indicated in the **index** variable (the fourth element). |
- | < | + | ===Using variables for array contents=== |
- | | + | As well, because we are putting values in our array elements that conform to particular data types, we can use variables there as well (in this case, put a 96 into the second array element-- using variables |
- | 09 | + | |
- | +09 | + | |
- | | + | |
- | | + | |
- | </code> | + | < |
- | Then we have the follow-up addition to determine the value of the 10s place: | + | int value = 96; |
+ | int index = 1; | ||
- | < | + | numbers[index] = value; |
- | 1 | + | |
- | 0 | + | |
- | +0 | + | |
- | -- | + | |
- | 1 <-- sum (of 10s position) | + | |
</ | </ | ||
- | and we would technically have a resulting carry of 0 (but adding zero to any values gives us the value itself-- the so-called | + | Hopefully these examples have proved useful with respect to basic concepts |
+ | |||
+ | We now explore the productive collaboration of arrays and loops: | ||
+ | |||
+ | ====Using loops and arrays together for universal harmony==== | ||
+ | |||
+ | To really make the most out of arrays in scaling our algorithms, using them in conjunction with loops gives us the most bang for our buck. The advantage of arrays+loops is that with the ONE consistent variable name, representing many NUMERICALLY-identifiable elements, | ||
+ | |||
+ | ===42 everywhere=== | ||
+ | |||
+ | To illustrate, here we will declare an 11 element array (called **data**), and fill each element with the value 42 using a for loop: | ||
+ | |||
+ | <code c> | ||
+ | int data[11], position = 0; | ||
+ | |||
+ | for(position = 0; position < 11; position=position+1) // see, using long form, could have done " | ||
+ | { | ||
+ | data[position] = 42; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===Display array contents=== | ||
+ | What if we wanted | ||
+ | |||
+ | Important considerations: | ||
+ | * again, with C, being true to how the computer actually works, we can only access the array one element at a time | ||
+ | * because we know array indices start at 0, we have a known starting point | ||
+ | * because we know how big our array is (11 elements, from previous example), we know how many elements to go for | ||
+ | * each element is located one after the other-- 0 is followed by 1 is followed by 2 etc. | ||
+ | |||
+ | ... therefore, we have all the ingredients for a **for** loop: | ||
+ | |||
+ | <code c> | ||
+ | for (position = 0; position < 11; position++) | ||
+ | { | ||
+ | fprintf(stdout, | ||
+ | } | ||
+ | fprintf(stdout, | ||
+ | </ | ||
+ | |||
+ | This should result in the following program output: | ||
+ | |||
+ | < | ||
+ | 42 42 42 42 42 42 42 42 42 42 42 | ||
+ | </ | ||
+ | |||
+ | ===Backwards? | ||
+ | What if we wanted to display the contents of our array in reverse (from position 10 to position 9, to 8, down to 0)? | ||
+ | |||
+ | We'd still want to use a loop, but look at how we structure it: | ||
+ | |||
+ | <code c> | ||
+ | for (position = 10; position >= 0; position--) | ||
+ | { | ||
+ | fprintf(stdout, | ||
+ | } | ||
+ | fprintf(stdout, | ||
+ | </ | ||
+ | |||
+ | Notice how the loop-terminating relational statements differ (comparing the two-- for forward and backward, does it make sense?), and also how we progress between individual elements (in one we are incrementing, | ||
+ | |||
+ | That should make sense before you try to proceed. | ||
+ | |||
+ | ===Thinking with arrays=== | ||
+ | Using arrays in your algorithms represents a potential barrier you have to overcome. Up until this point, we've been getting used to labelling all our variables with unique, individual names. | ||
+ | |||
+ | Now, with arrays, we have one common name, distinguishable by its element offset. That has been known to cause some conceptual problems due to the mildly abstract nature it creates. It would certainly not hurt to draw some pictures and manually work through some examples, step-by-step... it may be confusing at first, but the more you play with it, ask questions, play, read, etc., the sooner things will start to click. | ||
+ | |||
+ | As some of you have started to realize with **mbe0**, the actual core work of the project wasn't actually that hard, once you saw through the illusion of complexity | ||
- | Once we are all said and done, we concatenate the tens and ones places together: | ||
- | 1 (ten) and 8 (ones): 18 | + | ====Multiplying a number |
+ | In **mbe0**, we specifically looked at 3 usage cases for our mental math problem: 1-, 2-, and 3-digit number. I limited it to those because, lacking arrays and loops for that project, the code would have gotten impossibly long and complex, plus: I wanted you to focus on the basics of variable usage and if-statements. | ||
- | ====Multiplying any three-digit | + | Now that we have those down, we can now apply arrays and loops to optimize and enhance a solution, and to allow it to scale to a wider range of possibilities (why limit ourselves to just 1-, 2-, and 3-digit |
- | In this case we merely extend | + | |
- | Let's look at 123 x 11: | + | ===3-digits (review)=== |
+ | Again, to review, let's look at a 3-digit example. | ||
< | < | ||
- | 123 x 11 = 1 (1 + 2) (2 + 3) 3 | + | 123 x 11 = 1 |
- | = 1 3 | + | = (1 + 0) (3 + 0) 5 |
+ | = 1 | ||
= 1353 | = 1353 | ||
</ | </ | ||
Line 156: | Line 295: | ||
< | < | ||
567 x 11 = 5 (5 + 6) (6 + 7) 7 | 567 x 11 = 5 (5 + 6) (6 + 7) 7 | ||
- | = (5 + 1) (1 + 1) 3 7 | + | = (5)+1 |
= 6 | = 6 | ||
= 6237 | = 6237 | ||
Line 170: | Line 309: | ||
A dual benefit of this project is that in addition to extending your programming experience / understanding of C, you could develop this as a mental ability (that is where it originated), | A dual benefit of this project is that in addition to extending your programming experience / understanding of C, you could develop this as a mental ability (that is where it originated), | ||
+ | ===4-digits=== | ||
+ | Now let us process a 4-digit example (look for similarities to the 3-digit process, specifically how this is merely an expansion, or an additional step-- due to the additional digit): | ||
+ | |||
+ | 4567 x 11: | ||
+ | |||
+ | < | ||
+ | 4567 x 11 = 4 (4 + 5) (5 + 6) (6 + 7) 7 | ||
+ | = (4)+1 | ||
+ | = 5 | ||
+ | = 50237 | ||
+ | </ | ||
+ | |||
+ | Remember, we are processing this from right to left (so that the carry values can properly propagate). While there is no initial carry coming in, we'll add one anyway (0), so we see 13+0 (which is simply 13)... but because we're interested in place values, this is actually a sum of 3, carry of 1... and that one gets sent over to the next place (which has an 11)... so 11+1 will be 12, or sum of 2, carry 1... that carry will propagate to the next position to the left (the 9)... so there' | ||
+ | |||
+ | Can you see how "the same" this process for 4-digit numbers is when comparing to the process for 3-digit numbers? And how the same comparison can be made for 2-digit, and 5-digit, 6-digit, etc.? Please take some time, working through some examples (by hand) to identify and notice the pattern, or essence, of this process. You need to see how it doesn' | ||
+ | |||
+ | That " | ||
+ | |||
+ | (Also, the potential exception here would possibly be 1-digit values... if you cannot easily find a way to make 1-digit numbers work with greater-than-1-digit numbers, that's where an if-statement would come into play-- if 1-digit, do this specific process, else do the regular process). I'm not saying one universal solution isn't possible, but at this stage of your structured programming development, | ||
=====Program===== | =====Program===== | ||
- | It is your task to write the program that will use the above method | + | It is your task to write an optimized version of your multiply by eleven |
Your program should: | Your program should: | ||
* obtain its input from STDIN. | * obtain its input from STDIN. | ||
* input should be in the form of a single integer value | * input should be in the form of a single integer value | ||
- | * determine | + | * determine the number |
* perform the correct algorithm against the input | * perform the correct algorithm against the input | ||
* propagate any carries | * propagate any carries | ||
- | * output | + | * use an array (**digit**) to store individual digits from the number input |
- | * you can display each digit individually, | + | * use another array (**result**) to store the digits of the result number, following manipulations |
+ | * hint: you will want to make the **result** array one element larger. Why is this? | ||
+ | * Display output showing aspects of the process | ||
+ | * output the final value (by iterating through the array, displaying one value at a time) | ||
=====Execution===== | =====Execution===== | ||
Line 191: | Line 352: | ||
Enter value: 31415926 | Enter value: 31415926 | ||
Digits detected: 8 | Digits detected: 8 | ||
- | result[0] = 6 | + | |
- | result[1] = | + | Obtaining unique digits, storing in array... |
+ | digit[0] = 6 | ||
+ | digit[1] = 2 | ||
+ | digit[2] = 9 | ||
+ | digit[3] = 5 | ||
+ | digit[4] = 1 | ||
+ | digit[5] = 4 | ||
+ | digit[6] = 1 | ||
+ | digit[7] = 3 | ||
+ | |||
+ | Applying process... | ||
+ | result[0] = 6 + 0 + 0 (sum of 6, carry out of 0) | ||
+ | result[1] = 2 + 6 + 0 (sum of 8, carry out of 0) | ||
+ | result[2] = 9 + 2 + 0 (sum of 1, carry out of 1) | ||
+ | result[3] = 5 + 9 + 1 (sum of 5, carry out of 1) | ||
+ | result[4] = 1 + 5 + 1 (sum of 7, carry out of 0) | ||
+ | result[5] = 4 + 1 + 0 (sum of 5, carry out of 0) | ||
+ | result[6] = 1 + 4 + 0 (sum of 5, carry out of 0) | ||
+ | result[7] = 3 + 1 + 0 (sum of 4, carry out of 0) | ||
+ | result[8] = 3 + 0 + 0 (sum of 3, carry out of 0) | ||
+ | |||
+ | Displaying result... | ||
31415926 x 11 = 345575186 | 31415926 x 11 = 345575186 | ||
lab46: | lab46: | ||
Line 202: | Line 384: | ||
lab46: | lab46: | ||
Enter value: 7104 | Enter value: 7104 | ||
+ | Digits detected: 4 | ||
+ | |||
+ | Obtaining unique digits, storing in array... | ||
+ | digit[0] = 4 | ||
+ | digit[1] = 0 | ||
+ | digit[2] = 1 | ||
+ | digit[3] = 7 | ||
+ | |||
+ | Applying process... | ||
+ | result[0] = 4 + 0 + 0 (sum of 4, carry out of 0) | ||
+ | result[1] = 0 + 4 + 0 (sum of 4, carry out of 0) | ||
+ | result[2] = 1 + 0 + 0 (sum of 1, carry out of 0) | ||
+ | result[3] = 7 + 1 + 0 (sum of 8, carry out of 0) | ||
+ | result[4] = 7 + 0 + 0 (sum of 7, carry out of 0) | ||
+ | |||
+ | Displaying result... | ||
7104 x 11 = 78144 | 7104 x 11 = 78144 | ||
lab46: | lab46: | ||
Line 211: | Line 409: | ||
lab46: | lab46: | ||
Enter value: 56789 | Enter value: 56789 | ||
+ | Digits detected: 5 | ||
+ | |||
+ | Obtaining unique digits, storing in array... | ||
+ | digit[0] = 9 | ||
+ | digit[1] = 8 | ||
+ | digit[2] = 7 | ||
+ | digit[3] = 6 | ||
+ | digit[4] = 5 | ||
+ | |||
+ | Applying process... | ||
+ | result[0] = 9 + 0 + 0 (sum of 9, carry out of 0) | ||
+ | result[1] = 8 + 9 + 0 (sum of 7, carry out of 1) | ||
+ | result[2] = 7 + 8 + 1 (sum of 6, carry out of 1) | ||
+ | result[3] = 6 + 7 + 1 (sum of 4, carry out of 1) | ||
+ | result[4] = 5 + 6 + 1 (sum of 2, carry out of 1) | ||
+ | result[5] = 5 + 1 + 0 (sum of 6, carry out of 0) | ||
+ | |||
+ | Displaying result... | ||
56789 x 11 = 624679 | 56789 x 11 = 624679 | ||
lab46: | lab46: | ||
Line 216: | Line 432: | ||
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. | ||
- | =====Reflection===== | ||
- | Be sure to provide any commentary on your opus regarding realizations had and discoveries made during your pursuit of this project. | ||
- | |||
- | * Does this process work for four digit numbers? | ||
- | * How about five digit numbers? | ||
- | * Do you see a pattern for now this trick could be extended? | ||
=====Submission===== | =====Submission===== | ||
Line 227: | Line 437: | ||
* Code must compile cleanly (no warnings or errors) | * Code must compile cleanly (no warnings or errors) | ||
- | * Output must be correct, and match the form given in the sample output above. | + | * Output must be correct, and resemble |
* Code must be nicely and consistently indented (you may use the **indent** tool) | * Code must be nicely and consistently indented (you may use the **indent** tool) | ||
* Code must utilize the algorithm presented above | * Code must utilize the algorithm presented above | ||
Line 233: | Line 443: | ||
* have a properly filled-out comment banner at the top | * have a properly filled-out comment banner at the top | ||
* have at least 20% of your program consist of **< | * have at least 20% of your program consist of **< | ||
- | * Output Formatting (including spacing) of program must conform to the provided output (see above). | ||
* Track/ | * Track/ | ||
* 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 240: | Line 449: | ||
<cli> | <cli> | ||
- | $ submit cprog mbe1 multby11v2.c | + | $ submit cprog mbe1 mbe1.c |
Submitting cprog project " | Submitting cprog project " | ||
- | -> multby11v2.c(OK) | ||
-> mbe1.c(OK) | -> mbe1.c(OK) | ||