/* 
* Code Snippets for this week
* Small programs to show bits of C and bits of C. 
* >> I've tried to put * at the start of all the comment lines. 
*/

/* Selection Constructs
* if example
*/

#include <stdio.h>

int main(char *argv[], int argc)
{
    const int LIMIT = 5;

    int myNumber; 		/*create variable */
    scanf("%d",&myNumber);      /*read in number */

    if(myNumber > LIMIT)                       /* if condition */
    {
        printf("bigger than five \n");     /*multi line statement surrouned by {} */
        printf("rar\n");
    }
    else
        printf("not bigger than five\n");   /*single line statment no need for {} */

    return 0;
}

/* Comparision operators 
*
*   ==		equals
*   != 		not equals
*   >		greater than
*   >=		greater than or equal too
*   <		greater than 
*   <=		greater than or equal too
*   !           not - reverse something e.g. if !(a > b) 
*/


/* Selection Constructs
* switch example
*/

#include <stdio.h>

#define AWAKE 0
#define ASLEEP 1

int main(char *argv[], int argc)
{
    int response = 0;                                                     /* create variable */
    printf("Please enter 0 if you are AWAKE or 1 if you are ASLEEP\n");   /* ask for input */
    scanf("%d",&response);                                                /* read input */

    switch(response)                                 /* switch statement on variable */
    {
        case AWAKE:                                  /* 1st case - note use of labels */
            printf("I'm awake!\n");
            break;                                   /* must break - or fall though */
        case ASLEEP:                                 /* 2nd case - note use of labels */
            printf("ZZZZZ\n");
            break;
        default:                                     /* good practice to end with a default */
            printf("I didn't read the question\n");
    }
}
