Richard Hart offered up a bunch of free trials of his Unity 3D lessons over at Reddit, I got lucky and grabbed one early. I’m 8 out of the 25 lessons deep and enjoying it very much.
I feel like I’m making progress at the end of each very short lesson and that each is a great foundation in the software.

Go learn Unity 3D over at http://www.udemy.com/unity-tutorial/

So much fun ahead.

99 bottles in C

I tried this all on my own, yay me!

 

ascii chart

Now I’m unstoppable.

Glorious output!


 

 

while loop

I learned and started to rely heavily on the do…while loop for my C thinking days ago, but there’s more to it.

While loop in Lua.

 

for loop

This is the mother of all programming toys, because BASIC doesn’t have while loops, until later. Crazy right?

The FOR loop in C takes place inside the parenthesis as arguments to the function. i++ iterates the value of i+1 each repeat of the loop.

BASIC

Lua

 

greedy.c

The goal here was to produce the least number of coins for the given value.
I prototyped this in Scratch first, which made the C coding much easier, as I was able to look up the appropriate loop to use.

 

mario.c

This was easier than it looks, only took hours.
The trick was truncating two strings and concatenating them into a single string.

 

CS50x PSET01 part 1

Working on CS50xweek 2, here’s some example programs they asked me to write.
Note that GetFloat() is from the cs50 library included with the lesson material.

 

Not bad, moving right along, and I was totally unmotivated at the start of this.
Percentage finder, I got to use that do…while loop I learned the other day.

 

printf

In its simple form printf(“only requires quotes and a string”)  or a number. Ultimately though printf will output data held in variables. Special tokens are used inside of the string as place holders for these variables.

For instance if we have string variables such as:

This printf command uses %s as place holders for those strings:

The output would be:
Variable data and strings  with  more variable data inside of quotes followed by the variable names, each separated by a comma.

Variables could be elements like first and last names, addresses, or parts of speech for MadLibs, whatever comes up.

Note that C can’t declare a string as I did above.

We must declare a type char variable[n] where n is the depth of the array, or number of characters we intend to store inside of the string variable.

Here is an actual C program to demonstrate printf  and strings .

Note that %s is used as a place holder for the variables and the variables are inserted in the order given at the end of the printf statement.

If we were inserting numbers into our statement we’d use %d for digits like this:

 

OK I think I learned something.

Simplest C Program

How Stuff Works has a tutorial on C that I’m reading now. Here’s the program:

#include <libraries.h>
Libraries are pre-written code resources that provide services like i/o, math, graphics, etc.

int main()  
Every C program requires a main()

Curvy Braces { and } mark the beginning and end of a code block.

 

printf(“The format string\n”)
Part of the  <stdio.h> library, his example prints “The format string”  and a new line represented by “\n” to the standard output, usually the command line.

The font is a bit strange here but that “\ ” character is the backlash, found above the return  key.

return 0;
Returns an error code zero (no error) to the C shell.

Remember the closing curvy brace that completes the code block and note the semi-colons that mark the end of each line within the block.