This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
user:acrowle1:portfolio:cprogproject3 [2014/03/02 21:56] – [Reflection] acrowle1 | user:acrowle1:portfolio:cprogproject3 [2014/03/09 14:53] (current) – [Project: dayofweek] acrowle1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======Project: | + | ======Project: |
A project for CSCS1320S14 by Alana Whittier during the Spring Semester 2014. | A project for CSCS1320S14 by Alana Whittier during the Spring Semester 2014. | ||
Line 50: | Line 50: | ||
My first attempt at writing the program was using the modulus operator, %, although abandoned that effort quickly as it was not clear what to do with the factor in order to implement the mental math technique. I then decided to implement the computation of the square in what I deemed more simplistic of an approach and then used a series of if, else if statements to output **// | My first attempt at writing the program was using the modulus operator, %, although abandoned that effort quickly as it was not clear what to do with the factor in order to implement the mental math technique. I then decided to implement the computation of the square in what I deemed more simplistic of an approach and then used a series of if, else if statements to output **// | ||
- | Example 1: | + | Example 1 (My first submitted program): |
Line 94: | Line 94: | ||
After more consideration, | After more consideration, | ||
- | See the code below. | + | Example 2 (The second program using modulus operator and factor): |
Line 211: | Line 211: | ||
Second mistake: The way I used the curly braces. Essentially, | Second mistake: The way I used the curly braces. Essentially, | ||
- | Since my initial attempt at writing this program included the modulus operator, which had been quickly abandoned, I decided to revisit that since I now had a working program written in a manner I felt was more simplistic. | + | Since my initial attempt at writing this program included the modulus operator, which had been quickly abandoned, I decided to revisit that since I now had a working program written in a manner I felt was more simplistic. |
- | **Observations** | ||
- | The long and long long int (signed and unsigned) appear the same. This is because they are both 64 bit and that is the most the compiler can handle. | ||
- | printf() and fprintf() basically do the same thing. The difference being that printf can only print on the monitor, has the default stream of STDOUT, while fprintf can print to a user defined stream (or file). In our project, fprintf uses the STDOUT to the screen AS if it were a file. | ||
- | STDOUT is by default printed to the screen unless user specified. | ||
- | |||
- | %s is the format specifier used to print a string of characters, %hhu is the format specifier for half half unsigned char, % hu is the format specifier for unsigned short int. | ||
- | |||
- | The difference between %u and %d are that %u denotes an unsigned int type, while %d denotes a signed int type. | ||
- | |||
- | Considering the 13 in %13 in the first stanza for unsigned char in the program, this just specifies the number of characters in the string, including spaces to be printed for " | ||
- | |||
- | If a sign is left unspecified, | ||
- | |||
- | The & and | operators are the bitwise logic operators, which in our case took the hex representation of our data types to help us to obtain the appropriate high/low values within our ranges. | ||
- | |||
- | I experienced some difficulty in initial attempts to obtain the low values for the signed data types. I later learned that not only did I need to change the expression for the " | ||
- | |||
- | Based on my program' | ||
- | * signed char = 8 bits | ||
- | * unsigned short int = 16 bits | ||
- | * unsigned int = 32 bits | ||
- | * signed int = 32 bits | ||
- | * signed long long int = 64 bits | ||
- | |||
- | However, due to the decrementing and incrementing per data type, only the unsigned char actually stored ANY memory at all and stored a total of 16 bits! | ||
Line 252: | Line 227: | ||
In performing this project, the following resources were referenced: | In performing this project, the following resources were referenced: | ||
- | * http://en.cppreference.com/w/cpp/language/types1 | + | * http://wildaboutmath.com/2007/11/11/impress-your-friends-with-mental-math-tricks/comment-page-6/ |
- | * http://www.youtube.com/ | + | * http://saurabhg.hubpages.com/hub/ |
- | * http://www.binaryhexconverter.com/decimal-to-hex-converter | + | * Kernighan, Ritchie |
- | * http://en.wikipedia.org/wiki/Signed_number_representations | + | * email consultations and guidance from Matt Haas |