User Tools

Site Tools


haas:spring2020:cprog:projects:dtr0

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:spring2020:cprog:projects:dtr0 [2020/01/26 22:26] – [Scope] wedgehaas:spring2020:cprog:projects:dtr0 [2020/01/26 22:46] (current) – [Submit Tool Usage] wedge
Line 36: Line 36:
 The **sizeof()** and **printf()** functions, as well as arithmetic and logical operators, will be utilized in performing much of the work. The **sizeof()** and **printf()** functions, as well as arithmetic and logical operators, will be utilized in performing much of the work.
  
-=====Code=====+=====Grabbing project resources===== 
 +I have prepared a **grabit** for resources related to this project. To obtain:
  
-====Skeleton Program==== +<cli> 
-Here is the skeleton of a program you'll want to use for this project:+lab46:~/src/cprog$ grabit cprog dtr0 
 +make: Entering directory '/var/public/SEMESTER/cprog/dtr0' 
 +'/var/public/SEMESTER/cprog/dtr0/Makefile' -> '/home/wedge/src/cprog/dtr0/Makefile' 
 +'/var/public/SEMESTER/cprog/dtr0/dtr0.c' -> '/home/wedge/src/cprog/dtr0/dtr0.c' 
 +makeLeaving directory '/var/public/SEMESTER/cprog/dtr0' 
 +lab46:~/src/cprog$  
 +</cli>
  
-<code c> +At which point you can change into the newly created and populated **dtr0** directory.
-/* +
- * dtr0.c - A program to derive and display information +
-          for the signed and unsigned data types in C +
- * +
- * +
- * A program by NAME for COURSENUMBER COURSENAME (SEMESTER) +
- * +
- * Compile with: gcc -o dtr0 dtr0.c +
- Execute with: ./dtr0 +
- *+
-  +
-#include <stdio.h> +
-  +
-int main() +
-+
-    // Variables +
-    unsigned char uchr = 0; +
-     +
-    // Code for unsigned char +
-     +
-    // Code for signed char +
-     +
-    // Code for unsigned short int +
-     +
-    // Code for signed short int +
-     +
-    // Code for unsigned int +
-     +
-    // Code for signed int +
-     +
-    // Code for unsigned long int +
-     +
-    // Code for signed long int +
-     +
-    // Code for unsigned long long int +
-     +
-    // Code for signed long long int +
-  +
-    return(0); +
-+
-</code>+
  
-====unsigned char code block==== +Please study the **dtr0.c** program, and look up or ask questions on aspects that you do not understand.
-Following is provided code giving you the requested information for an **unsigned char**. Study it, implement it, and adapt it as needed to the other data types:+
  
-<code c> +Compile it.
-    // Code for unsigned char +
-    fprintf(stdout, "TYPE: %13s, ", "unsigned char"); // What is happening here? +
-    fprintf(stdout, "bytes: %lu, ", sizeof(uchr));    // Why does sizeof() need %lu? +
-    fprintf(stdout, "low: %hhu, ",  (uchr & 0x00));   // Why 2 zeros? +
-    fprintf(stdout, "high: %hhu, ", (uchr | 0xFF));   // Why 2 F's? +
-    uchr = uchr - 1;                                   // What does this line do? +
-    fprintf(stdout, "qty: %hu\n",   (uchr+1));        // What is going on here? +
-</code> +
- +
-Note that by adapting, you'll need to declare and initialize additional variables, and you may "unroll" some of the logic here to do it in more discrete steps (in fact, it may enable you to solve a couple problems that crop up).+
 =====Execution===== =====Execution=====
  
 <cli> <cli>
 lab46:~/src/cprog/dtr0$ ./dtr0 lab46:~/src/cprog/dtr0$ ./dtr0
-TYPE: unsigned char, bytes: 1, low: 0, high: 255, qty: 256 
-TYPE:   signed char, bytes: X, low: X, high: X, qty: X 
-TYPE: unsigned short int, bytes: X, low: X, high: X, qty: X 
-TYPE:   signed short int, bytes: X, low: X, high: X, qty: X 
-... 
-lab46:~/src/cprog/dtr0$  
 </cli> </cli>
- 
-This output includes some mock additional entries, actual values abstracted. Instead of displaying 'X', your program should display the actual values, and display a total of 10 lines, for the signed and unsigned variations of the five data types we are studying in this project. 
  
 =====Reflection===== =====Reflection=====
 Be sure to provide any commentary on your journal regarding realizations had and discoveries made during your pursuit of this project. You should also consider adding extra comments into your program so that it can be a more valuable reference going forward. Be sure to provide any commentary on your journal regarding realizations had and discoveries made during your pursuit of this project. You should also consider adding extra comments into your program so that it can be a more valuable reference going forward.
  
-Alsoanswer the following questions:+=====Your task===== 
 +You are to create a text filecalled "**dtr0.text**" that you will submit for this project. It will contain your well-thought-out responses to the following questions:
  
   * What two data types appeared "the same"?   * What two data types appeared "the same"?
-    * Why may this may be? +    * Why is this the case?
-    * Is this universal for all systems, or just a certain subset?+
   * With respect to **printf()**:   * With respect to **printf()**:
     * What is the difference between **printf()** and **fprintf()**?     * What is the difference between **printf()** and **fprintf()**?
Line 125: Line 72:
     * What is the difference between **%s**, **%hhu**, **%hu**?     * What is the difference between **%s**, **%hhu**, **%hu**?
     * How about **%u** and **%d**?     * How about **%u** and **%d**?
-    * What does the **13** in **%13s** do for us?+    * What does the **22** in **%22s** do for us?
   * If sign was left unspecified, which state is assumed by default?   * If sign was left unspecified, which state is assumed by default?
   * What are the **<nowiki>&</nowiki>** and **<nowiki>|</nowiki>** operators?   * What are the **<nowiki>&</nowiki>** and **<nowiki>|</nowiki>** operators?
-    * How did they help you achieve the solution? +    * What are they doing to enable the display of the output?
-  * If you experienced trouble displaying the total quantity for a certain type, why was this?+
   * Based on your program's output, what are the total **bits** allocated for:   * Based on your program's output, what are the total **bits** allocated for:
     * signed char     * signed char
Line 193: Line 139:
  
 <cli> <cli>
-lab46:~/src/cprog/dtr0$ submit cprog dtr0 dtr0.c+lab46:~/src/cprog/dtr0$ submit cprog dtr0 dtr0.text
 Submitting cprog project "dtr0": Submitting cprog project "dtr0":
-    -> dtr0.c(OK) +    -> dtr0.text(OK) 
  
 SUCCESSFULLY SUBMITTED SUCCESSFULLY SUBMITTED
Line 206: Line 152:
  
 <code> <code>
-39:dtr0:final tally of results (39/39+13:dtr0:final tally of results (13/13
-*:dtr0:submitted file called dtr0.[3/3+*:dtr0:submitted file called dtr0.text [4/4
-*:dtr0:committed and pushed dtr0.c to repository [4/4] +*:dtr0:committed and pushed dtr0.c and dtr0.text to repo [4/4] 
-*:dtr0:adequate and consistent indentation in dtr0.[4/4] +*:dtr0:sufficient info in dtr0.text [5/5]
-*:dtr0:sufficient comments in dtr0.[4/4] +
-*:dtr0:utilizes correct and best fit printf format specifiers [4/4] +
-*:dtr0:executable runs without issue [4/4] +
-*:dtr0:output is correct [4/4] +
-*:dtr0:output conforms to project specifications [4/4] +
-*:dtr0:adequate modifications in dtr0.c [4/4] +
-*:dtr0:no compiler warnings nor errors for dtr0.c [4/4]+
 </code> </code>
  
haas/spring2020/cprog/projects/dtr0.1580077590.txt.gz · Last modified: 2020/01/26 22:26 by wedge