Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101winter2015/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/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/feed-rss2.php on line 8
‘#coding’ Articles at Courses by Ken https://kenscourses.com/tc101winter2015 Facilitator of Learning Experiences Mon, 06 Apr 2015 02:12:35 +0000 en hourly 1 https://creativecommons.org/licenses/by/4.0/ mastery 24 https://kenscourses.com/tc101winter2015/2015/mastery-24-6/ Mon, 06 Apr 2015 02:12:35 +0000 https://carlosgreenprograms.withknown.com/2015/mastery-24 Continue reading ]]>

++  

Arrays are a good way to store a determined amount of numbers given by the user. You can either enter the size of the array, and that will be the maximum f numbers that will fit in. Just so, you can create a variable in order to ask the user for the size of the array and that way you can ask as many numbers as the user wants to provide. When using arrays in functions, you need to replace your variables in the main() code, so you can ask the user for the size of the array and then ask for each number using a “for” loop or a “do while” loop.

here is an example:

<iostream>

<cstdlib>

 using namespace std;

 

 int average(int x[], int size){

   int sum=0, average;

 

   for(int i=0; i<size; i++){

     sum=sum+x[i];

   }

   average=sum/size;

   return average;

 

 }

 int main(){

   int size;

   int a[size];

   cout<<“give me the amount of numbers “<<endl;

   cin>>size;

   for(int i=0; i<size; i++){

     cout <<“give me a number “;

     cin>> a[i];

 }

 cout<<average(a,size);

 }

]]>
https://creativecommons.org/licenses/by/4.0/
mastery 16 https://kenscourses.com/tc101winter2015/2015/mastery-16-3/ Mon, 16 Feb 2015 14:42:52 +0000 http://carlosgreenprograms.withknown.com/2015/mastery-16 Continue reading ]]>

 

here is my code for mastery 16 showing the use of “else” as a conditional.

here is my code for masteries 15 and 16

<iostream>

using namespace std;

 

int main(){

  int a, c, d;

  char b;

 

  cout <<“does it move? 1) yes 2) no”;

  cin >> (a);

  if (a == 1) {

    cout << “should it move? 1)yes 2)no”;

    cin>>(c);

    if (c == 1) {

      cout << “then no problem 8)”;

 

    }

    else {

      cout << “then use duct tape”;

     }

 

 

 

    }

    else {

      cout <<“Should it move? 1)yes 2)no”;

      cin >>(d);

      if (d==1) {

        cout << “then use DW40”;

    }

    else {

      cout <<“then no problem 8)”;

    }

  }

  return 0;

}

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