User Tools

Site Tools


notes:cprog:fall2023:projects:mmf0

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
notes:cprog:fall2023:projects:mmf0 [2023/09/17 23:33] – [Quarter the value] jbernatanotes:cprog:fall2023:projects:mmf0 [2024/02/26 06:30] (current) – [else] hcopp1
Line 7: Line 7:
 ====Obtain the last two digits of this input value==== ====Obtain the last two digits of this input value====
  
--In order to obtain the last two digits of this input value, you can create a new variable and set that to be the result of the input year variable, divided by the integer division remainder (%) followed by 100. This is because a four-digit number, divided by 100 will yield a remainder in the tenth's place. This tenth's-place number will be what you are looking to use for the next steps in the project.+-In order to obtain the last two digits of this input value, you can create a new variable and set that to be the result of the input year variable, divided by the integer division remainder (%) followed by 100. This is because a four-digit number, divided by 100 will yield a remainder in the tenth's and / or hundredth's place. This decimal-place number will be what you are looking to use for the next steps in the project.
    
 -For example: short unsigned int new = year % 100 -For example: short unsigned int new = year % 100
Line 15: Line 15:
 NOTE: Use () to ensure the code does things in the order you want. NOTE: Use () to ensure the code does things in the order you want.
 ====Add quartered value back to two digit year==== ====Add quartered value back to two digit year====
 +Add quartered value to the last two digits of the current year.
 ====Subtract best fitting multiple of seven==== ====Subtract best fitting multiple of seven====
  
Line 22: Line 22:
 ^  Day  ^  Value  | ^  Day  ^  Value  |
 |  Monday  |  1  | |  Monday  |  1  |
 +^  Day  ^  Value  | 
 +|  Tuesday  |  2  | 
 +^  Day  ^  Value  | 
 +|  Wednesday  |  3  | 
 +^  Day  ^  Value  | 
 +|  Thursday  |  4  | 
 +^  Day  ^  Value  | 
 +|  Friday  |  5  | 
 +^  Day  ^  Value  | 
 +|  Saturday  |  6  | 
 +^  Day  ^  Value  | 
 +|  Sunday  |  7  | 
 +^  Day  ^  Value  | 
 +|  Sunday  |  0  |
 ====Edge case: leap years==== ====Edge case: leap years====
  
Line 28: Line 41:
  
 ====if statements==== ====if statements====
 +if statements are written as "if (condition){ the thing you want to happen }
  
 +If the condition is not met, "the thing you want to happen" is skipped over.
 ====else if==== ====else if====
  
 +<color #ed1c24>ELSE IF</color> is put at the end of a <color #00a2e8>IF</color> statement. <color #ed1c24>ELSE IF</color> will first check if the condition of the original <color #00a2e8>IF</color> statement was met, if it wasn't met, It then prompts another <color #c8bfe7>IF</color> statement 
 +
 +Example:
 +<code>
 +if (condition0) 
 +{
 +     If condition0 is met do this ....
 +
 +else if (condition1) 
 +{
 +     if condition0 isn't met and condition1 is; Do this ....    
 +}
 +</code>
 ====else==== ====else====
  
 +
 +ELSE is put at the end of a IF statement. ELSE will first check if the condition of the original IF statement was met, if it wasn't met, It then does something 
 +
 +Example:
 +<code>
 +if (condition0) 
 +{
 +     If condition0 is met do this ....
 +
 +else  
 +{
 +     if condition0 isn't met do this ....    
 +}
 +</code>
 ====RELATIONAL OPERATORS==== ====RELATIONAL OPERATORS====
  
 ^  Operator  ^  Description  | ^  Operator  ^  Description  |
 |  ==  |  is equal to  | |  ==  |  is equal to  |
 +|  !=  |  is not equal to  | 
 +|  <    greater than  | 
 +|  >    less than  | 
 +|  < =  |  less than or equal to  | 
 +|  > =  |  greater than or equal to  |
 =====VERIFY RESULTS===== =====VERIFY RESULTS=====
 To verify your results, ./mmf0verify To verify your results, ./mmf0verify
  
 Remember to only use **stdout** to print the days of the week [EX: fprintf(stdout, “Monday\n”)]. If **stdout** is used for anything other than the days of the week, the mmf0verify will say you have a mismatch for every year, even if you get the correct day when you run your compiled code. If you want to print something other than the days of the week, use **stderr**.  Remember to only use **stdout** to print the days of the week [EX: fprintf(stdout, “Monday\n”)]. If **stdout** is used for anything other than the days of the week, the mmf0verify will say you have a mismatch for every year, even if you get the correct day when you run your compiled code. If you want to print something other than the days of the week, use **stderr**. 
notes/cprog/fall2023/projects/mmf0.1694993627.txt.gz · Last modified: 2023/09/17 23:33 by jbernata