Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/feed-rss2.php on line 8
‘#DoubleMastery’ Articles at TC101 Fall 2015 https://kenscourses.com/tc101fall2015 Introduction to Programming Python and C++ Thu, 29 Oct 2015 01:29:02 +0000 en hourly 1 https://creativecommons.org/licenses/by/4.0/ Mastery 19 & Mastery 20 https://kenscourses.com/tc101fall2015/2015/mastery-19-mastery-20/ Thu, 29 Oct 2015 01:29:02 +0000 http://octavioirg.wordpress.com/?p=127 ]]> CC licensed photo by Vox Efx on Flickr
CC licensed photo by Vox Efx on Flickr

Hello everybody, this post is to explain the basic use of while loops and for loops.

While is a loop that will be performed if the conditions inside its definition is true. Yes, you are right… again boolean value. If the condition inside the while returns the value true then the code under the while is performed.

For loop are more classy and I love them. Once you understand how it is used, a for loop is good for almos everything. For loops works with the next principle, you have a numer, you add orr substract from that number until a condition is met. For example:

for(i = 0; i<N; i++)

In this example first part befor the semicolon means the initial value of i is equal to cero, then in the second part before the second semicolon this means that the loop is going to be performed until i stops being less than N, the last part before the last brace means that i is going to increment by 1 each time the cycle is completed.

In the next videos this situation is better explained, the first video is mine and the second is someone’s else video I found on Youtube:

Maybe it is much better explained in this second video… just maybe

P.S.: Remember the words of the second’s guy video: a loop repeats a block of code, we are going in circles for a certain number of times.

]]>
https://creativecommons.org/licenses/by/4.0/
Mastery 15 & Mastery 16 https://kenscourses.com/tc101fall2015/2015/mastery-15-mastery-16-2/ Thu, 29 Oct 2015 01:01:24 +0000 http://octavioirg.wordpress.com/?p=125 ]]> Picture by Moyan Brenn on Flickr.
Picture by Moyan Brenn on Flickr.

This post is for mastery points 15 and 16:

So this time it is about conditional if and using else with a conditional

As you may know, an if statement is a fairly simple conditional, yet you can do very interesting things with it. It’s different from a for cycle because with the if condition you only write one parameter. If the parameter is true then the condition is met and the programm performs the piece of code under de condition.

Using else is useful when you have two situations. If the condition is not met in the previous if, then the code under de else statement is going to be performed. As I said, the if statement works with true or false, therefore you could say that an if statements works based on boolean algebra.

The following video is me talking a little about if statements and using else with it. 🙂


]]>
https://creativecommons.org/licenses/by/4.0/
Mastery11 & Mastery12 https://kenscourses.com/tc101fall2015/2015/mastery11-mastery12/ Wed, 28 Oct 2015 19:58:06 +0000 https://octavioirg.wordpress.com/?p=120 ]]> This post is for mastery points 11 and 12.

CC licensed photo by Mario Klingemann on Flickr
CC licensed photo by Mario Klingemann on Flickr

I created a video explaining how to create a function and then call it later in your code. Believe me it’s really easy.

First you should know that a function is a predefined piece of code contained like in a capsule. Each time ou need the code you call the function and use the code inside of it. You can write your own functions or use the functions that are contained in the different C++ libraries.  Another definitions for function could be: “a group of statements that is given a name, and which can be called from some point of the program”.

To create a function you need to write the type of data that its going to return, because functions have to return something. Then you have to name your function and say what its going to transform. That’s right, as you may have figured out, functions take something, perform a transformation and return something else. It’s like a little a machine.

Look at the following example:

// function example
#include <iostream>
using namespace std;

int addition (int a, int b) /*the first int means that this function is going to return an interger, the second and third int's mean that this function takes an int called "a" 
another int called "b".*/
{
  int r;
  r=a+b;
  return r;
}
/*in this part of the function you declare another variable, this is called a local variable because is used only in the function. The variable is going to store the value of the sum of "a" and "b". Then you need to say what is going to return the function, in this cases we return r becauce that is the value we want.*/
int main ()
{
  int z;
  z = addition (5,3);
  cout << "The result is " << z;
}

References:

http://www.cplusplus.com/doc/tutorial/functions/

]]>
https://creativecommons.org/licenses/by/4.0/
Mastery11 & Mastery12 https://kenscourses.com/tc101fall2015/2015/mastery11-mastery12-2/ Wed, 28 Oct 2015 19:58:06 +0000 http://octavioirg.wordpress.com/?p=120 ]]> This post is for mastery points 11 and 12.

CC licensed photo by Mario Klingemann on Flickr
CC licensed photo by Mario Klingemann on Flickr

I created a video explaining how to create a function and then call it later in your code. Believe me it’s really easy.

First you should know that a function is a predefined piece of code contained like in a capsule. Each time ou need the code you call the function and use the code inside of it. You can write your own functions or use the functions that are contained in the different C++ libraries.  Another definitions for function could be: “a group of statements that is given a name, and which can be called from some point of the program”.

My video: http://youtu.be/jltHibh6GN4?hd=1

To create a function you need to write the type of data that its going to return, because functions have to return something. Then you have to name your function and say what its going to transform. That’s right, as you may have figured out, functions take something, perform a transformation and return something else. It’s like a little a machine.

Look at the following example:

// function example
#include <iostream>
using namespace std;

int addition (int a, int b) /*the first int means that this function is going to return an interger, the second and third int's mean that this function takes an int called "a" 
another int called "b".*/
{
  int r;
  r=a+b;
  return r;
}
/*in this part of the function you declare another variable, this is called a local variable because is used only in the function. The variable is going to store the value of the sum of "a" and "b". Then you need to say what is going to return the function, in this cases we return r becauce that is the value we want.*/
int main ()
{
  int z;
  z = addition (5,3);
  cout << "The result is " << z;
}

References:

http://www.cplusplus.com/doc/tutorial/functions/

]]>
https://creativecommons.org/licenses/by/4.0/