/* 
* 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. 
*/

/*
* Basic ''Hello World'' 
*/
#include <stdio.h>

int main(int argc, char* argv[])
{
    printf("Hello World \n");
    return 0;
}

/* Special characters for printf 
*
* "\n" -> newline 
* e.g. 
*/

printf("Line with a new line at the end \n");

/* 
*
* "\t" -> tab     
* e.g. 
*/

printf("Line with a tab \t in the middle");

/* Placeholder types 
* 
* "%d" -> int e.g. "Outputing an int %d"
* "%f" -> float e.g. "Outputing a float %f"
* "%c" -> char e.g. "Outputing a char %c"
* 
*/

/*
* Variable types, assignment and IO
*
*/

/* *** Integer example *** 
*
* Full program, only copy one main in at a time!
*/


/* io library for printf and scanf */
#include <stdio.h>

int main(char* argv[], int argc)
{

    /* 4 bytes long - whole number*/
    int anInteger; 

    /* Assignment */
    anInteger = 4;

    /* printf - printing out */

    printf("I haz an int %d some other text blah blah \n", anInteger);
    /*      ^out text     ^placeholder                      ^what to put in placeholder

    /* scanf - reading in */

    scanf("%d", &anInteger);
    /*    ^placeholder 
                 ^address of variable to read into */

    printf("changed to %d\n",anInteger);
}

/* *** Float example *** 
*
* Full program, only copy one main in at a time!
*/

int main(char* argv[], int argc)
{

    /* 4 bytes long - floating point number */
    int aFloat; 

    /* Assignment - must include f otherwise assumes double */
    aFloat = 4.0f;

    /* printf - printing out */

    printf("I haz an int %f some other text blah blah \n", aFloat);
    /*      ^out text     ^placeholder                      ^what to put in placeholder

    /* scanf - reading in */

    scanf("%f", &aFloat);
    /*    ^placeholder 
                 ^address of variable to read into */

    printf("changed to %d\n",aFloat);
}

/* **** Maths **** 
*  Operations
*    +         Add
*    -         Subtract
*    *         Multiply
*    /         Divide / Div (integer division if both numbres are ints)
*    %         Mod (remainder). 
*
*/


