User Tools

Site Tools


haas:spring2015:cprog:projects:mbe1

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
haas:spring2015:cprog:projects:mbe1 [2015/02/06 19:35] – [Program] wedgehaas:spring2015:cprog:projects:mbe1 [2015/02/07 13:31] (current) wedge
Line 6: Line 6:
 ~~TOC~~ ~~TOC~~
  
-======Project: MENTAL MATH - MULTIPLY BY 11 (mbe0)======+======Project: MENTAL MATH - MULTIPLY BY 11 (mbe1)======
  
 =====Objective===== =====Objective=====
Line 337: Line 337:
   * perform the correct algorithm against the input   * perform the correct algorithm against the input
   * propagate any carries   * propagate any carries
-  * use an array to store individual digits+  * use an array (**digit**) to store individual digits from the number input 
 +  * 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 (see example execution below)
   * output the final value (by iterating through the array, displaying one value at a time)   * output the final value (by iterating through the array, displaying one value at a time)
  
Line 349: 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:~/src/cprog/mbe1$  lab46:~/src/cprog/mbe1$ 
Line 360: Line 384:
 lab46:~/src/cprog/mbe1$ ./mbe1 lab46:~/src/cprog/mbe1$ ./mbe1
 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:~/src/cprog/mbe1$  lab46:~/src/cprog/mbe1$ 
Line 369: Line 409:
 lab46:~/src/cprog/mbe1$ ./mbe1 lab46:~/src/cprog/mbe1$ ./mbe1
 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:~/src/cprog/mbe1$  lab46:~/src/cprog/mbe1$ 
Line 374: 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 385: 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 the form given in the sample output above.
   * 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 391: 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 **<nowiki>//</nowiki>**-style descriptive comments     * have at least 20% of your program consist of **<nowiki>//</nowiki>**-style descriptive comments
-  * Output Formatting (including spacing) of program must conform to the provided output (see above). 
   * Track/version the source code in a repository   * Track/version the source code in a 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 398: Line 449:
  
 <cli> <cli>
-$ submit cprog mbe1 multby11v2.c mbe1.c+$ submit cprog mbe1 mbe1.c
 Submitting cprog project "mbe1": Submitting cprog project "mbe1":
-    -> multby11v2.c(OK) 
     -> mbe1.c(OK)     -> mbe1.c(OK)
  
haas/spring2015/cprog/projects/mbe1.1423251338.txt.gz · Last modified: 2015/02/06 19:35 by wedge