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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831
{"id":24652,"date":"2015-10-28T08:53:53","date_gmt":"2015-10-28T14:53:53","guid":{"rendered":"http:\/\/opezaimd.tumblr.com\/post\/132085132385"},"modified":"2015-10-28T08:53:53","modified_gmt":"2015-10-28T14:53:53","slug":"masteries-11-12-7","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2015\/2015\/masteries-11-12-7\/","title":{"rendered":"Masteries 11 & 12"},"content":{"rendered":"

On these masteries I\u2019m going to show you what are functions <\/p>\n

in C++<\/p>\n

,how to create one, and how to call it in your program,<\/p>\n

Functions allow you to create\u00a0\u201cmini programs\u201d inside your code in order to make it shorter (and better).<\/p>\n

So, let\u2019s recall what we did on mastery 10<\/a>.\u00a0<\/i><\/b>We will practice with the same concept, the addition of two numbers, but now we will do it with functions.<\/p>\n

The big difference with using functions in your program is that you need to write them before our\u00a0\u201cbasic code\u201d which is the int main ().\u00a0<\/p>\n

So, what you will need to do first is our \u201cbasic code\u201d:<\/p>\n

<\/figure>\n

Now, if we would want the program to add two numbers that the user inputs, we could write the code inside int main (), declare the three variables (x being the first number the user inputs, y being the second number, and z being the result), then ask the user for these two variables, and then simply add them like this:<\/p>\n

<\/figure>\n

And then if we run the program, it will work like this:<\/p>\n

<\/figure>\n

And that just works fine, but it will work and look better if we use functions, and as I told you before, functions are written before int main (). So, do as follows:<\/p>\n

    \n
  1. Write an int function called addition below\u00a0\u201cusing namespace std;\u201d Inside the parentesys you should declare your variables<\/li>\n
  2. Return an operation that adds your two variables.<\/li>\n<\/ol>\n

    Your funtion should look something like this;<\/p>\n

    <\/figure>\n

    Now that you have your function, you can call it inside int main (), but you need to declare the variables inside here too. So, do as follows:<\/p>\n

      \n
    1. Declare your two variables inside int main ()<\/li>\n
    2. Ask the user for these two variables.<\/li>\n
    3. Call your function using cout.<\/li>\n<\/ol>\n

      Your program now should look something like this:<\/p>\n

      <\/figure>\n

      Now let\u2019s run and test it:<\/p>\n

      <\/figure>\n

      And that\u2019s about it! You know now how to create a function and how to use it, congrats!<\/p>\n","protected":false},"excerpt":{"rendered":"

      On these masteries I’m going to show you what are functions <\/p>\n

      in C++<\/p>\n

      ,how to create one, and how to call it in your program,<\/p>\n

      Functions allow you to create “mini programs” inside your code in order to make it shorter (and better).<\/p>\n

      So, let’s recall what we did on mastery 10<\/a>. <\/i><\/b>We will practice with the same concept, the addition of two numbers, but now we will do it with functions.<\/p>\n

      The big difference with using functions in your program is that you need to write them before our “basic code” which is the int main (). <\/p>\n

      So, what you will need to do first is our “basic code”:<\/p>\n

      <\/figure>\n

      Now, if we would want the program to add two numbers that the user inputs, we could write the code inside int main (), declare the three variables (x being the first number the user inputs, y being the second number, and z being the result), then ask the user for these two variables, and then simply add them like this:<\/p>\n

      <\/figure>\n

      And then if we run the program, it will work like this:<\/p>\n

      <\/figure>\n

      And that just works fine, but it will work and look better if we use functions, and as I told you before, functions are written before int main (). So, do as follows:<\/p>\n

        \n
      1. Write an int function called addition below “using namespace std;” Inside the parentesys you should declare your variables<\/li>\n
      2. Return an operation that adds your two variables.<\/li>\n<\/ol>\n

        Your funtion should look something like this;<\/p>\n

        <\/figure>\n

        Now that you have your function, you can call it inside int main (), but you need to declare the variables inside here too. So, do as follows:<\/p>\n

          \n
        1. Declare your two variables inside int main ()<\/li>\n
        2. Ask the user for these two variables.<\/li>\n
        3. Call your function using cout.<\/li>\n<\/ol>\n

          Your program now should look something like this:<\/p>\n

          \"Masteries<\/figure>\n

          Now let’s run and test it:<\/p>\n

          <\/figure>\n

          And that’s about it! You know now how to create a function and how to use it, congrats!<\/p>\n","protected":false},"author":230,"featured_media":24651,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[219,128,129,40,611],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/24652"}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/users\/230"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/comments?post=24652"}],"version-history":[{"count":1,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/24652\/revisions"}],"predecessor-version":[{"id":24653,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/24652\/revisions\/24653"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/media\/24651"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/media?parent=24652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/categories?post=24652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/tags?post=24652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}