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
‘#Mastery23’ Articles at TC101 Fall 2015, Page 3
Introduction to Programming Python and C++

Tag Archives: #Mastery23

Mastery 23: Creation and use of vectors in C++

HI n_n here is the video: https://youtu.be/npMa7m7qfE0
Thanks for watching!!

#MASTERY23

Mastery #23

How to use vectors in c++ http://prezi.com/igdrnrzr2chj/?utm_campaign=share&utm_medium=copy

Mastery #23

How to use vectors in c++ http://prezi.com/igdrnrzr2chj/?utm_campaign=share&utm_medium=copy

MASTERY #23: Creation and use of vectors in C++

(Credit of the image goes to https://flic.kr/p/8VLQwq) Hello everyone. This Mastery #23. If you are interested in learning about vectors, feel free to read this Power Point I made: MASTERY 23 Also watch the following example:

MASTERY #23: Creation and use of vectors in C++

Hello everyone. This Mastery #23. If you are interested in learning about vectors, feel free to read this Power Point I made: MASTERY23 Also watch the following example:

Arrays, vectors, loops… masteries!

Hello, niggers. Here a program which ask the user for the age and stature of three persons and then print the data: The code: https://github.com/hrglez/TC1017/blob/master/Stature Have a nice day, fellows.

Arrays, vectors, loops… masteries!

Hello, niggers. Here a program which ask the user for the age and stature of three persons and then print the data: The code: https://github.com/hrglez/TC1017/blob/master/Stature Have a nice day, fellows.

Using Vectors!

Hello, fellows. Here a code where I kind of explain the basic use of vectors: Be aware that you have to include a new library for using vectors. The main code: https://github.com/hrglez/TC1017/blob/master/VectorSample Have a nice day!

Vectors and Arrays #Mastery23 #Mastery24

Vectors and Arrays are important tools to store a determined or undetermined quantity of values for further use. They will be developed during this post.

Vectors can store a determined set of values, initialize the values or assign them further in the code. Here are the several ways of using vectors. 

First a vector could be initialized as:

                vector Name (Number of values);

This will create a vector containing a certain type of data (which could be strings, integers, floating points, among others). The number of values will be the available spots within the vector. After the initialization each spot could be filled with a value by making reference to it. For example, in a vector which name is MyVector with 2 spots, values could be assigned by typing this:

               MyVector[0]= 0;

               MyVector[1]= 100;

Note: remember that the first spot within a vector is number 0.

Another way of initializing values would be:

               vector Name (Number of values, 5);

This would give each spot within the vector a value of 5 or any number after the comma. Also it can be done as:

                vector Name = {1,2,3,4,5};

which would create a vector with 5 spaces filled by the numbers written, in this case: 1,2,3,4,5.

A feature of the vectors is that you may obtain the number of spots within a vector by using the funtion size(), which would be used as: MyVector.size();

In case an additional space is required a new spot could be assigned by using the function push_back(), used as: MyVector.push_back(Value);

Finally, you may use the value within a vector for any task required, by calling them by typing the name of the vector and the spot. Which would be: MyVector[0], and would return the value in the first spot of the vector.

Here’s a code that uses a vector and its different functions to return the sum of the squares of given values:

        

Note: In order to use a vector and its commands, you should incude the vector library by starting the code with:

Arrays are simplier but with several disadvantages. The structure of an array might be:

type Name [Number]; 

Type would be any type of data such as strings, integers or floating points. Name any name you wish to assign to the array and finally the number of available spots within the array. A disadvantage of the arrays is that they have a fixed number of values that can not be modified as in the vectors. A direct initialization might also be possible by typing:

type Array [5] = {1,2,3,4,5};

Which creates an array called Array containing 5 values: 1,2,3,4,5. As in vectors, arrays can also be called and modified. For example:

Array[0]= Array[0]+2;

which changes the value of the array 0 which was 1 and turns it into 3.  

An interesting feature of arrays is the possibility of using multiple dimensions of the array. For instance, if we want to create a bidimensional array of integers we have to type:

int Array [n][m];

n and m stand for any integer value.

In order to understand easier this concept, we might think it as a row and column arrangement with coordinates to call each value. This image might help you visualize the concept:

Image Source: http://www.findmemes.com/c-memset-2d-array

Both turn useful if you intend to use several values and interact with them. The one you use depends on the task requested and on your personal preference if its a limited number of values, else you should use a  vector.

Hope this have helped you with this concepts. Thanks for browsing!

What should you work on?

Week #12 and more partial exams for you.

For this week's readings:
C++ (TC1017) should either be looking at support for your project, ImageMagick C++ libraries are a good start.
Python (TC1014) should be finishing chapter 11 (Dictionaries).