# Final Study Guide

Here is a list of topics to study:

• What is C?
• Order of Operations
• String vs Array
• Logical operators
• Random numbers
• Extra types
• File I/O
• Modulo math
• Integer division
• Garbage values (always initialize variables)
• 2-D Arrays

## Math

### Order of Operations

Remember that Order of Operations in C is like Order of Operations in normal math:

• Anything in parentheses () is first
• / and % are next
• and - are last

### Integer Division

Some of you may have seen this when you were working on your projects. These two math problems look different to C:

``````int number1 = 70 / 100; // This is 0
float number2 = 70.0 / 100.0; // This is 0.7
``````

Remember to check if you are doing integer or floating point division when you write code.

### Modulo Math

Make sure you know how Modulo works. Remember, Modulo takes the Remainder of a division:

``````10 / 3 = 3 (1 extra)        10 % 3 = 1
20 / 7 = 2 (6 extra)        20 % 7 = 6
4 / 10 = 0 (4 extra)        4 % 10 = 4
``````

## Variables

### C Keywords

There are 40 words in C that you cannot use for naming variables of functions. These words are called Keywords, and you can find a complete list of them on the Basic Syntax webpage. Here are a few examples: `int`, `float`, `char`, `if`, `else`, `do`, `while`, `for`, `switch`, `case`, `break`, `void`.

### What happens if you set a variable to nothing?

What would be the output of this code?

``````int x;
printf(“The number is: %d”, x);
``````

This code would output Garbage, because we did not give `x` a value. It would look like this:

``````The number is: 3486543245
``````

You should always stop this from happening by giving a value to a variable when you create it, like this:

``````int x;
printf(“The number is: %d”, x);
``````

### Other types

There are other types besides `int`, `char` and `float`. The list of them is on the Variables page.

## Strings

Read the page about arrays and the page about strings. Also, remember that Strings are not like the other types (`int`, `float` and `char`). Strings are really arrays of type `char`.

Also, remember what strings look like in the computer’s memory:

01234567
'C''h''r''i''s''\0''\0''\0'

### Escape characters

We’ve learned about ‘\n’, ‘\0’ and ‘\t’. In C these are called escape characters. Escape characters let you talk about characters that are hard to show. For example:

• \u - for writing UNICODE characters (like Thai letters)
• \f - Line feed, a little bit like ‘\n’
• \” - Quotes, for when you want quotes inside of a string, like this “I read the book \”Harry Potter\” by J.K. Rowling”
• \ - Backslash, in case you want a real backslash in your string.

## What should I do after this class?

I'm very proud that you've all learned to program in C, which is a very hard language.

If you liked programming, but you thought C was very hard, there are other languages you should try.

The Language Python is very easy to read and write. Here is the Hello World program for Python:

``````print "Hello World!"
``````

It has no `main()` function, no brackets {}, no semicolons and no weird symbols. Here's an if statement:

``````a = 1
b = 2

if a < b and not b > 7:
print "Yes"
``````

I have a whole page full of stuff you can try out, if you want to keep programming. Happy Hacking!