Monday, May 12, 2014

Class of May 12, 2014

          Today was the last class of this semester. We reviewed for the final which is good because I want to get an A in the test in order to get an A in the course. I really learned a lot through out the semester and now I have to keep practicing in order to get better.

Wednesday, May 7, 2014

Class of May 7, 2014

          In today's class we discussed dynamic arrays. Dynamic arrays are arrays whose size is determined when the program is running, not when you write the program. I believe that these arrays are better than static arrays because they are more flexible and allow the user to determine the size.

Monday, May 5, 2014

Class of May 5, 2014

Happy Cinco de Mayo!!

          In today's class, we discussed pointers, the new operator, and the delete operator. Pointers tell us where a variable is located. It is really simple to understand.

To declare pointers:
ex: double *p;

The address of operator:
ex: p1 = &v1

The new operator creates a pointer to a new "nameless" variable of type int.
ex: p1 = new int

The delete operator immediately releases the memory space that will no longer be used by the program. This is a great tool since it prevents a program from taking all the memory.
ex: delete p;


Friday, May 2, 2014

Class of May 2, 2014

     In today's class, among many topics we discussed vectors. Vectors are like arrays that can change size as your program runs.

To declare a vector:

vector <int> v;

To access vector elements:

v[i] = 45;

cout << v[i];

To initialize vector elements we use the member function push-back. This adds the element in the next available position.

Don't forget to include the vector library!!

#include <vector>

Wednesday, April 30, 2014

Class of April 30, 2014

          In today's class we discussed chapter 8, "Strings and Vectors". It is important that when working with strings always leave an extra space in the elements for the null character '\0' which declares where the string ends. Declaring a C-string variable is done using an array of characters.

For example:
        char s[11];

         Returning to what I said earlier about saving an extra space character, declaring a C-string as char s[11] creates space for only 10 characters since the null character terminator requires the other (1) space.

Monday, April 28, 2014

Class of April 28, 2014

     In today's class, the professor discussed some concepts that after reading over the next lab assignment I know will help me in completing it. I am getting better at arrays I just need a little bit more practice. Hopefully during summer I will be able to complete some problems from COJ.

Friday, April 25, 2014

Class of April 25, 2014

      In today's class we discussed arrays in functions. They are declared using empty brackets. I need to review this concept once more to understand it better. Today we also discussed searching arrays. One way to search an array for a given value is to look at each element from first to last to see if the target value is equal to any of the array elements.