From e46bafab2c9e31fadad2840b31288517b47187b8 Mon Sep 17 00:00:00 2001 From: knolax <1339802534.kk@gmail.com> Date: Thu, 3 May 2018 21:13:33 -0400 Subject: added review notes --- 4-28-notes.txt | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ cont/index.html | 10 ++-- index.html | 29 ++--------- 3 files changed, 159 insertions(+), 33 deletions(-) create mode 100644 4-28-notes.txt diff --git a/4-28-notes.txt b/4-28-notes.txt new file mode 100644 index 0000000..137dceb --- /dev/null +++ b/4-28-notes.txt @@ -0,0 +1,153 @@ +Variables +"They're something in a program that stores values, this can be a number, a\ +character, a pointer a float or arrays of those things." + +Variable Type +"the type of a variable is what sort of thing the variable is, what kind of\ +value it stores, what operators work on it and the size of it" + +Examples +int integer = 34; +char character = 'a'; +char * string = "1234"; +float floating-point = 12.0; +double doubleFloatingPoint = 111112.0; +int * pointer = &integer; +int array[4] = {0,2,3,4}; + +Special types of integers + +unsigned int unsignedInteger = 4; +short shortInteger = 5; +long longInteger = 1212121212122121212; +uint8_t unsigned8bitInteger = 255; +uint32_t unsigned32bitInteger = 323232323233223232323; + +printf("Hello World! %d %c %s\n\a",122,'A',"A String"); + +"printf is a function a part of stdio(Standard I/O) that allows a program to\ +print to serial out(the terminal) it takes a format string and values after that" + +Format String +"The format string is what you want printf to print out with, with stuff like\ +%d that are placeholders that let you also print out the value of variables you\ +supply to printf as arguments" + +so in printf("hello world!\n"); "hello world!\n" is the format string + +'\n' and '\a' are special characters, '\n' stands for new line and is like +pressing enter. '\a' is the alarm bell and makes a beeping sound + +%d is a placeholder for an integer, printed out in decimal(base 10) +%c is a placeholder for a character +%s is a placeholder for a string + +for more information look at 'man printf' + +What is a function? +"A math function is a when a domain is paired to a co-domain, in programming,\ +piece of code that you can run multiple times and does an action" + +Function return +"the value a function outputs" + +Function argument +"the input to a function" + +//How do you run a function +foobar(foo, bar); +also known as a function call; +a function is also an expression +printf("hello world"); is a function call, you're running printf with the +argument "hello world." +"where foobar(int, int) is a function and foo and bar are arguments +that whole piece of code would then evaluate to the output of foobar" +eg. +"if foobar(foo, bar) outputs jia +then foobar(foo, bar); == jia" + +Function Definition +"defining a function is when you write down what a function takes as arguments, +what the function returns and what code the function runs" + +unsigned int foobar(int foo, int bar) { + int lar = 0; + lar = (foo - bar) * 82 + bar; + return lar; +} + +"the above is a function that returns a variable of type 'unsigned int' and +takes two arguments foo and bar that are of type 'int'. it runs the code inside +of the squiggly brackets {}." + +Code blocks + +"any code inside of an {} are a code block, you can put code blocks inside of +code blocks, that's called nesting code blocks. When you make a new code block +you should indent the code inside of the block" +printf("foobar\n"); +i++; +if( i == 0) { + printf("barfoo\n"); + j++; +} +"you indent, by putting a tab in front of every line, a tab is a big space" +"When you have a nested code block, you indent another level, or have an extra +tab in front of every line" +foobar +while (barfoo){ + foobar + if (baz) { + qux + bazqux + } + foobarbaz +} + +Foo Bar Baz Qux +"Foo Bar Baz Qux are placeholder names , they don't mean anything and you can +put your own stuff in place of them." +https://www.ietf.org/rfc/rfc3092.txt for more information + +Variable Declarations and Assignments +//When you declaring a variable, you tell the compiler that there is a variable +//named foo of type bar that now exists. You can only use a variable after +//declaring/defining it. +int foo; +//however, right now foo is "uninitialized", meaning there is no value being +//stored in foo, which means you can't use it. Initializing a function is just +//giving it a value. +foo = 0; +//a function that is defined and initialized +bar = 12; +//assigning a value to a variable just changes the value stored by a variable. +foo = 10; +foo = bar; +foo = foobar(12); + +foobar(34); + +Statements and Expressions +"Expressions evaluate to a value, where as statements do a thing. In c all \ +statements are also expressions but you can ignore that" +a + b //is a statement +foobar(34); is a statement because function calls are statements +if (a + b) {} is an if statement +i++; increments i or adds 1 to it. + +PRACTICE/REVIEW: +"identify the parts of the below code" + +int main(int argc, char * argv[] ) { + if(argc > 1) { + printf("you gave me %d arguments\n",argc); + } else { + printf("you didn't give me any arguments\n"); + } + return argc - 1; +} + + + + + diff --git a/cont/index.html b/cont/index.html index 5307a22..84a1b58 100644 --- a/cont/index.html +++ b/cont/index.html @@ -39,13 +39,6 @@ http://hairydiode.xyz and this site from scratch)
  • Basic Computer Security(best practices, CTF challenges)
  • Robotics (Head programmer at the Urbana Mandelbots FTC team)
  • -

    -I have been: -

    - Course Details ---Required Course Materials

    A dedicated laptop that Linux will be installed on, this can be any @@ -129,3 +122,6 @@ Network Secruity)

  • c - Hosting your own website with github.io
  • + +---Review Notes: +April 28rd Session Review Notes diff --git a/index.html b/index.html index 5149e5e..a740c95 100644 --- a/index.html +++ b/index.html @@ -18,7 +18,6 @@ educational programs offered by schools are often aimed towards the lowest common denominator, oversimplifying things to the point where your child loses interest in them.

    - For Course Notes scroll down

    The Urban Computing and Electronics Summer Program aims to provide a balance between this, offering practical and challenging course material, but also providing in person tutoring for those who have little prior experience. @@ -52,13 +51,6 @@ http://hairydiode.xyz and this site from scratch)

  • Basic Computer Security(best practices, CTF challenges)
  • Robotics (Head programmer at the Urbana Mandelbots FTC team)
  • -

    -I have been: -

    - Course Details ---Required Course Materials

    A dedicated laptop that Linux will be installed on, this can be any @@ -142,24 +134,9 @@ Network Secruity)

  • c - Hosting your own website with github.io
  • -C expressions course notes -

    -Bitwise Operators: &, bitwise and; |, bitwise or; ~, bitwise not; ^, bitwise xor. -Bitwise operators apply logic operations in each position of a binary number, -return the resulting binary number. -

    -

    -Boolean Operators: &&, boolean and; ||, boolean or; !, boolean not. -Boolean operators apply logic on whether then entire number is true or false, -and returns true or false. -

    -

    -Comparisons: >, greater than; <, lesser than; >=, greater than or equals; -<=, lesser than or equals; ==, equals; !=, does not equal. -

    -

    AND: if both are true, then the output is true. OR: if one is true, then the -output is true. XOR: if one is true and the other false, then the output is -true, otherwise it is false. NOT: if true, false; if false, true.

    + +---Review Notes: +April 28rd Session Review Notes