Monday, May 16, 2011

Challenge Lesson 8 Source Code

List of videos Challenge 1
First Challenge NOTE: for a fast copy, follow these steps in order:
  1. Click anywhere in the text box below (result will be a blinking vertical line in the text box
  2. Hit ctrl + A on the key board (the "ctrl + A" means hit Ctrl and A at the same time) (The result should be that all the text inside the text box lights up in blue)
  3. Hit Ctrl + C (Nothing significantly happens that is visible) and now its copied to the clipboard and your ready to paste it anywhere you wish
Solution 1
Solution 2

Tuesday, May 10, 2011

Lesson 11 Source Code

List of videos Lesson 11 Video
To get the full benefit of the lesson, watch the video Lesson 11: Introduction to the if statement NOTE: for a fast copy, follow these steps in order:
  1. Click anywhere in a text box below (result will be a blinking vertical line in the text box)
  2. Hit ctrl + A on the key board (the "ctrl + A" means hit Ctrl and A at the same time) (The result should be that all the text inside the text box lights up in blue)
  3. Hit Ctrl + C (Nothing significantly happens that is visible) and now its copied to the clipboard and your ready to paste it anywhere you wish

if statements
The if statement will only take bool parameter (value inside the paranthesis). The if statement will either skip or execute the following program statement depending on the boolean value of the if statement. Run both of these pieces of code. refer to the video for the detailed explanation. the if statement can also refer to code blocks (code inside curly braces) to skip multiple lines of code. you can input variables into th if parameter. You can also put in int, double, char, etc types but don't forget the rules of the boolean values that aren't true or false. Here are slightly more practical examples that might help you see why if statements are useful

Tuesday, April 26, 2011

Lesson 20 Source Code

List of videos Lesson 20 Video
Lesson 20: The while loop part 3: break statement NOTE: for a fast copy, follow these steps in order:
  1. Click anywhere in the text box below (result will be a blinking vertical line in the text box
  2. Hit ctrl + A on the key board (the "ctrl + A" means hit Ctrl and A at the same time) (The result should be that all the text inside the text box lights up in blue)
  3. Hit Ctrl + C (Nothing significantly happens that is visible) and now its copied to the clipboard and your ready to paste it anywhere you wish
A prime number algorithm
Here is an infinite loop that we have encountered in the past. This is a bug that can be very difficult to find. We can add a condition in the while loop parameter that changes each time by using a counting variable.
Prime number algorithm
In this program, you will enter a positive Integer value for a, and it will tell you if that number is prime or not Here is the algorithm that prints off many prime numbers to the screen. Just enter an Integer value for x and it will print off that many random numbers. from 2 to x is the range of values that will be printed. a is the variable we are testing to see if its prime or not. n is the divisor that determines if it really is prime or not. Notice that when you escape from the second while loop, n has to be set back equal to 2 because in the we need to start off dividing the next number by 2 just as we have been doing for the first number.

Lesson 16 Source Code

List of videos Lesson 16 Video
Lesson 16: The while loop NOTE: for a fast copy, follow these steps in order:
  1. Click anywhere in a text box below (result will be a blinking vertical line in the text box)
  2. Hit ctrl + A on the key board (the "ctrl + A" means hit Ctrl and A at the same time) (The result should be that all the text inside the text box lights up in blue)
  3. Hit Ctrl + C (Nothing significantly happens that is visible) and now its copied to the clipboard and your ready to paste it anywhere you wish
beginning while loop examples
This will print my name 5 times to the screen This program code will count from 0 to 24 This program will NEVER END. This is a common bug called the infinite loop This program will double the value of "a" and print it out to the screen until a is greater than 500 (NOTE: There is only 1 difference compared to the program above this one) This program will dived a by 2 each time until a is 0;

Sunday, April 24, 2011

Lesson 10 Source Code

List of videos Lesson 10 Video
To get the full benefit of the lesson, watch the video Lesson 10: The bool (Boolean) type NOTE: for a fast copy, follow these steps in order:
  1. Click anywhere in a text box below (result will be a blinking vertical line in the text box)
  2. Hit ctrl + A on the key board (the "ctrl + A" means hit Ctrl and A at the same time) (The result should be that all the text inside the text box lights up in blue)
  3. Hit Ctrl + C (Nothing significantly happens that is visible) and now its copied to the clipboard and your ready to paste it anywhere you wish

small char programs
Boolean types can hold either true or false If the value is set a number that is not equal to 0 the boolean value will be set to true If the value is set to 0, the boolean value will be considered false.

Lesson 9 Source Code

List of videos Lesson 9 Video
To get the full benefit of the lesson, watch the video Lesson 9: The char type NOTE: for a fast copy, follow these steps in order:
  1. Click anywhere in a text box below (result will be a blinking vertical line in the text box)
  2. Hit ctrl + A on the key board (the "ctrl + A" means hit Ctrl and A at the same time) (The result should be that all the text inside the text box lights up in blue)
  3. Hit Ctrl + C (Nothing significantly happens that is visible) and now its copied to the clipboard and your ready to paste it anywhere you wish

small char programs
The char can only hold ONE character. that character has to be inside single quotations. Initializing and assigning multiple variables

Friday, April 22, 2011

Lesson 8 Source Code

List of videos Lesson 8 Video
To get the full benefit of the lesson, watch the video Lesson 8: The cin statement NOTE: for a fast copy, follow these steps in order:
  1. Click anywhere in a text box below (result will be a blinking vertical line in the text box)
  2. Hit ctrl + A on the key board (the "ctrl + A" means hit Ctrl and A at the same time) (The result should be that all the text inside the text box lights up in blue)
  3. Hit Ctrl + C (Nothing significantly happens that is visible) and now its copied to the clipboard and your ready to paste it anywhere you wish

The cin statement
The cin statement allows the user to enter a value for x in this example notice that the cin.get() statement is replaced by the system("pause") because the cin.get() will not work once cin has been called. (i don't know why that is the case) Here is another example. Computers don't like to divide by zero, you can try to input 0 for y to see what happens or you can also find out what happens by watching the video.