Discrete Math!

Yooooooooo! It’s been such a long time everybody! I’ve been SOOOO BUSY!! Doing all my stuff! But alas! I am back! Why? Because anxiety is taking over and when this happens you must blog! And also exercise! I exercised first! Whoppee! Denise Austin always helps me with my anxiety deals!

So, w0w! I see this website has changed a bit. It looks kinda nicer! 🙂

O.k! Guess what? My semester starts on August 13, 2014, long sigh, and that’s what makes me so anxious. I know there’s still some time left but I keep thinking that I definitely will not have time to do absolutely everything I wanted to do before going back and I also keep thinking about other things that I don’t want to get into and I also keep thinking that I only enrolled in 4 classes and that I might not be able to take one of them because when they finally decide the time of the course it might clash with other more important courses~~~ This is making me upset~~~ Because of all my mistakes I feel like I’ll NEVER graduate I must look like the biggest loser in the world~~~ 😦 😦 😦

But anyway I’m here to discuss the 3 classes that I KNOW I’ll take no matter what this semester. First of all I’ll be taking discrete math and boy am I afraid~ Someone told me our professor will be French, isn’t that kinda great? I want to enroll in a class to learn French but there was no space for me. 😦 That’s what I get for enrolling late. I left it all to the last minute ’cause I was too depressed and was thinking of dropping out. I wish I could promise myself never to get depressed but~~~~~~~~~~~~  But anyway yay! French prof!

France_Grunge_Flag_by_think0

I wonder if the prof will be female or male and more importantly will I understand the class?!?!?!

These are most likely the sections we’ll be covering:

-Logic  

-Set theory

-Combinatorics  

-Graph theory

-Probability  

-Number theory

-Algebra  

-Calculus of finite differences, discrete calculus or discrete analysis  

-Geometry  

-Topology

Am I afraid? Yes am I determined to be less stupid and negative and more open minded? Yes.

Look at what this guy is saying about how to understand it, sounds fair enough~

O.k watch this one! It’s a lot better. Now I feel all motivated to learn html coding!! Oooh!

Did you know discrete mathematics is also called finite mathematics? I just learned that in this video. 

O.k so I’m watching another video right now and apparently combinatronics has to do with counting methods, oooh! There are 4 types of counting: 1. Sequences, repetition is allowed. Apparently you can also call it permutation~ Order matters.

2. Arrangements= No repetition allowed. Order matters. Oooh he lost me when he began to program~~~

3. Subsets=order doesn’t matter and you can’t repeat. OMG! They’re suddenly talking about the binomial coefficient (n;k) I took some of that in Calculus 2 when we were studying series!

4. Multisubsets=order doesn’t matter but you can repeat. Ahaha! lol. New thing. it’s the same as the binomial coefficient but it has two pars (()) like that! Apparently it’s called n multichoose k 

((n;k))

So the video that I’ve been watching is pretty long and discrete math looks pretty hard, like Linear Algebra….

BTW did you know that when something is congruent it means they have the same shape and size? Yeah you prolly know that from elementary school geometry, with the triangles and all. I remember I did but I had completely forgotten about it, gee.

So this is the symbol for it:

vinyl-decal-sticker-1298The top line can be wavy if you want. It still means the same thing.

Oh God this video was mad long and boring. Watch it if you must, the guy is a great speaker though!

 

Well this post proved to be messy! Sorry! I’ll be back soon!! 😉

 

One hour of CODE!!!!!!!!!!!!!

Yaaaaaaaaaaay!!! I finally completed an hour of code at code.org! Remember that website I told you guys the prof told us to go check out and I did but decided I was waaay too busy to do the hour right away so I would do it during the summer? Well I finally did and it was MAGICAL!!! So much fun but kinda easy because I already know all the basics from the class so I kinda did it in less than an hour! But check out what they sent me:

Image

Waaah! So COOL!!! But guess what? There’s a lot more stuff I can learn here! So I’ll keep doing that later because I have LIKE A TON OF things I HAVE TO DO THIS SUMMER!! So many things I wanna do! For example, remember that competition I went to in Bayamon well remember how I said I solved none of the problems? I’m trying to solve them. So far I’m still on the first problem but I told myself I wouldn’t work on it today because I’m super stuck and it’s making me upset and I have WAAAY too much to this summer. Like doing the hr of code if I didn’t do that I was gonna BLOW!!!!!!!!!! Urr- Oooh check this out (they gave me a silly certificate for participating, I got it that same day but I didn’t post it here that day when I made my competish post because I felt a little bit upset that day because someone  was acting up that stupid day he ruined the whole field trip for me!!! Thank God I met all the guys from the picture and they saved the day. Thank Goodness!! Ugh— Otherwise I would’ve been sad but I wasn’t! Yay! 

Image

The one from code.org is kinda prettier. lol. Sorry about blurring my last name but I have to protect myself. lolololololololol. 

So anyway! I got mah grades!! Wanna know what I got? Disgustingness!!! That’s what it was— Well I guess it could’ve been worst— I mean for all the emotional garbage I went through 4 NO GOOD reason except that I’m a major drama queen I could’ve done a lot worst considering all the time I spent crying, lol. Yeah!! Guess what now that I’m done with the class I can write all the embarassing things I couldn’t write when the prof was reading my blog! LOL!!! So anyway! My grades? I got an A!!!!!!!!! on Comp 3010!!! Yes!!!I feel like I can actually say that I triumphed! Ahaha! Because that was my goal!

Image

Guess what was one of the things that saved me?! THIS BLOG!!!!!!!!!!!! I ❤ u, blog!!!!!!!!!! I got 100%!!! On the blog!!!!!!!!!! Wheeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee!!! I told ya I was a blogger at <3!!!!!!!!!!!!!! You know it’s funny  so far I have two certificates on programming even if they’re kinda meaningless they show I’m into this stuff. Guess how many certificates I have on Chemistry? Zero. Not that I deserve them anyway. But neeee I don’t think chem is that exciting. Only kinda but I still love it even if I’m betraying it. I’m sorry but programming was my first love anyway. Teehee! Well anyway! At least I got an A on Biology and an A on Organic Chemistry but not on the others………. I got B’s!!!!!!!!! NOOOOOOOOO!!! WHY CAN’T I KEEP UP HERE?!?!?!?!!!!!!!!!!!!!!!!!!!!!!! I’m such an IMBECILE!!!! Who cares! I’m not going to Harvard anyway! Plus I’ve never been smart I was just really really motivated in my previous university.

But here every time I went inside a classroom I was like:  “Why am I here? Can I leave?” Except at the comp class where I was like: “Why am I studying Chemistry? Can I stop?” I mean I ❤ chemistry. THe organic chemistry lab was like the FUNNEST thing in the planet!! We did SOOOOO MANY CRYSTALS!!!!!!!!!!!!!!!!!!! Wee!!! But still, eh whatever.

 

 

Is this Good-bye? Part 2

Hi!!! After a goodnight’s sleep I feel awesome! And now I can continue this really long post! 

Now we move on to chapter 8: Strings and vectors

Image

Ok we’ll talk more about C-strings and strings when I do my review for my final test. But a C-string is this primitive(I think) thing where you can store text and it turns out it’s an array for saving text. So to declare a C-string you declare a char array, like this:

char s[#];

So anyway if you ask me this is exactly the same as an array… What’s the diff? I’m confused. Gotta ask the prof or figure it out on the way.

The thing is that not only do we have C-strings but we also have Strings. C-strings are faster but not as convenient. Strings are a class so I understand this means they’re modern and guess what? They have like a ton of member functions that make our life easier!

Now in my notes we move on to vectors. I’ve never used them in an actual program yet but I am looking forward to it because they are extremely dynamic so the way I see it they’re fun!

Watch this video, this kid pretty much explains what’s on my notebook except for that member function pop_back. Weird.

 

Well if you didn’t feel like watching the video here’s how you declare a vector like so:

vector<doubleorwhatevertype>v(#)

v is the number of my vector and where you see the # well you’re suppose to write the size you want there but if you don’t wanna you don’t have to. Oh did you know these thingies <> are called angular brackets? Yeah you probably did. Everyone was calling them thingies in class it was funny. It took me back to my high school days! Yeah the capacity of the vector is what it’s allocated to it!♥ The size is what is used.

Now in my notes we suddenly move to chapter 9! GASPS!!!!!!!!!!! I gotta finish reading chapter 8!!! Because the thing is that I kinda started reading it but I already knew a few things about strings and we didn’t need to know that much about vectors for lab 7 so I kipped it and read chapter 9 because I knew NOTHING about pointers and dynamic arrays. 

So What are pointers? Watch vid! :p

This one bored me though… lolololololol

pointer=variable that can hold address of another variable. The prof wants us to keep in mind that pointers are not difficult!

OMG so apparently there’s this function sleep(#) that makes the program sleep for # of seconds so cool haven’t used it yet this has nothing to do w/ pointers but it was on my notes~

O.k so for some reason we go back to vectors in my notes. Weird huh?

I have this question in my notebook. What is a template? So I just went to the cpluplus reference and this is what they told me: “Function templates are special functions that can operate with generic types. This allows us to create a function template whose functionality can be adapted to more than one type or class without repeating the entire code for each type.”

A vector is a class template. When you do the <int> you are instantiating it, providing a type. Initially the vector is empty. Vectors are similar to arrays but they start their life with no elements. No garbage! Yay!

Then here in my notes I have the exact same push_back thing the kid did on the video so I’m not gonna go over it again. Oh! But here’s another member function the kid didn’t cover! It’s sample.size() for when you wanna now the size of the vector kinda analogous to .length for strings! The size is never negative, just sayin’.

Bit pattern=representation of a value

unsigned int= all the bit patterns are used for post values. ***Not sure of what that means but it’s in my notebook lol.

This was on the video but remember: If you wanna use vectors DON’T forget to include #include <vector>

Oh and check this out:

if you do this vector<int> v; You have a vector of elements but if you do this:

vector<vector<int>> v; you have a vector with a lot of other vectors inside! This reminds me of Physics, lol.

Allocation of memory is costly… Hmm don’t know what he was referring with that…

Going back to pointers…(my notes are topsy-turvy)

dereference operator = * = take the address go there and use the variable at that address.

The value of pointers is always an address. The only way to store an address is in a pointer. Array parameter variables are pointers.

So there’s this thing called the delete operator with it you give up your rights to access the address the pointer was pointing to. Apparently after you delete a pointer you can’t do anything until you assign a fresh address. After deleting dereferencing is undefined.

A dangling pointer is a pointer that points to a dynamic variable that has been released.

There’s another thing, the new operator. Although I had been using it in lab 7 I feel like I hadn’t really gotten it until maybe now? O.k first you create the pointer like this, right?

MyType *myptr

But then you call it with new! Ok! I get what I was doing with new. Calling it! Like this:

myptr = new MyType

Anyway there’s this other weird thing that I don’t get very well, apparently these two things are the same:

d[i] and *(d+i)

BTW  in a for you can actually have two update actions, you just gotta separate them with a comma!

A for without an initialization or an update action is the same as a while!

When you have a weird thing that looks like this **r (two stars) that’s a pointer to a pointer. This *q[300] is a pointer static array. 

And finally all I wanna say is that the final test is on May 16th and that it looks super hard! The prof gave us a practice test I would like to discuss some of the questions here:

Question 1-b: Explain what a dangling pointer is. How do they occur? What is the danger they present? Earlier we said a dangling pointer is a pointer that points to a dynamic variable that has been released. They occur when you release a dynamic variable that had a pointer pointing to it. When you do this the pointer variable becomes undefined and so does the pointer. Undefined pointers are dangling pointers. The danger they present is that the pointer is now undefined and if you apply the dereferencing operator the result is unpredictable and often disastrous.

Question 2-a: C-strings and strings. How are they alike and how are they different. For each, describe scenarios in which it would be preferred over the other.

Similarities:

1. Sequences of characters

2. Similar functionality

Differences:

1. The way they are stored. C-strings are stored in arrays, strings… I don’t know gotta ask prof…

2. C-strings are low level. Strings are more convenient.

3. C-strings take less time. Drawback of strings=there’s overhead on the operations. Extra work because of all the convenience they provide. They have to do checks and those take time. There’s a little bit of overhead in memory too.

***If time is important use a C-string if convenience is important use strings.

Question 2-b: Dynamic arrays and static arrays. How are they alike and how are they different?

Similarity:

1. Functionality

2. There can be pointer static arrays and dynamic arrays are alwasy done with pointers.

Difference:

1. The static array has a fixed value at compile time. You can’t use a variable to contain the size. In any case you can use a constant for the size. With the dynamic array you can use a variable that way the user can decide the size of the array.

***Choose the static array when I know the size I want. I choose the dynamic array when the size is basically up to the user.

The other three questions on the practice final are programs that you have to explain or give the output.

As for my COJ adventures I ended up being able to complete a total of 7 problems!! YAAAAAAAAAAAAAAY!!! A lot more than expected but not enough AT ALL!!! Some kid did like 48!! I’m such a loser!! No matter I’ll do more problems during the summer but those won’t count as extra credit. Boo~~~~ Plus now all the ones left are the really hard ones. I gotta read them and see what happens. But no matter what I need to develop my thinking ability if I ever wanna be a boss programmer!!! YEAH!!!

Image

Woooohohohoho!! Look at ME!!!!! I’m on 64 NOW!!! MUST BECOME AT LEAST 3!!!!!!!!! I ♥ COJ!!! But you know there are sooooooooooooooooooooooo many things that I need to do during this summer that we’ll just have to see how this goes. lol~~

Image

So why is this good-bye? It’s not!! lololol!! It’s just that I wasn’t sure of what I would do with my blog after the class was over! But now the decision is as clear as day! I’ll keep it! I love this blog so I’ll continue to study with it!! Remember how I was studying chemistry? Well now I’m almost 100% sure that I’ll change to computer science and graduate with enough determination!!! I still need to see one of their counselors though… Uuuugh but the secretary at the math dept is always mean to me… lol. So yeah! I’ll try to write about the stuff I learn in my next comp science class and since it’s not for class credit I can go wild and write about other things. I guess what we’re saying good-bye to is the formalities of this blog and to an amazing class and to a REALLY REALLY STUPID semester!!! ROAR!!! You know around the beginning of May I realized that I wasted my entire semester being depressed over silly things and that that’s one of the reasons why I failed all my classes I shouldn’t have cared and continue to concentrate.. Urrr… I’m such a loser~ When I say fail all my classes I mean I’m seeing little opportunity to pass any classes with an A except Biology. That’s the only one I have an A in. I have an 88 on this if I don’t mess the final up I guess I could get an A? Will the COJ and competition extra credit save me???? I hope so!!!!!!!!!!!!! I want an A on this class and I wanted one in Organic Chemsitry too but uh yeah…… Don’t see how that will happen…. As for my other classes I now know that I suck and complain too much and I don’t stand a chance. Urrr 😦 I can’t believe I used to be 4.00 before I came here.. lol. I thought that I would be able to keep up here too……. Pffffffff. Well I hope I waste less time being depressed next semester and CONCENTRATE!! I’m more positive about next semester because I’ll be taking comp classes that get me all pumped to do what I have to do except that they make me depressed too when I can’t solve the problem at hand lol! But let’s not think about the negatives~~~ Well good-bye semester!!! I doubt you will be missed. My first semester here (The one before this one lol cause I’m basically new here lol) was a lot better and lot more fun!! 🙂

Is this good-bye? Part 1

The semester is almost over!!!~~~ And summertime is coming! Whooo!!! So before we get into plans for the future, comp adventures and good-byes I want to update you w/ all I learned since my last post and before, lol. We take our last comp3010 class on Monday and then THE FINALS BEGIN!!!

Oh dear! So last time I posted something about what we learn in class here was about arrays!! That’s chapter 7!! Now we’ve covered all the way up to chapter 9. So we’ll have to go through what I didn’t discuss last time about chapter 7, those marvelous multidimensional arrays and chapters 8 and 9.

For lab 7 I had to do a two dimensional array and these videos are amazing! They tell you how to do it and how to print it out looking nice in a nutshell! Bucky is great! Check out his website while you’re at it!!

There’s a lot you can do with multidimensional arrays but they can get really complicated. Especially if you have deals, like me. Because for lab 7 I was trying to do a 3-dimensional array for this problem called LIFE and I was doing a double for and I was getting error messages and a lot of stress going on and then someone points out that duh! I need a triple for if I have 3D array. So you, know now I know that if it’s a 4D then I need 4 fors and so on!!!But the funny thing is that with a 1D you can do cool tricks w/ double fors like this that I did this morning:

Image

 

You see a 1D array with a double for. I also did that here:

Image

My point is, the amount of fors doesn’t neccesarily depend on the dimension but on what you wanna do with the array but you can only have more fors than the dimension not less ’cause if you have less you won’t be able to tell the program the exact positions in the array well unless you use a number on one of the brackets and then do the i’s and j’s on the others I guess…

So did I ever tell you guys that you cannot return an array? If you want a function that “returns” an array just use a void function and do a for to cout the thing right the thing. Array parameters are great because they change the array they are pointer parameters and kinda do what the call-by-reference parameters do.

Now let’s talk about what will happen if an index value that does not exist is entered. Well it will go to an address one of the things that could happen is that the memory location for that index already contained a variable and it overtakes the variable, changes the value and ruins everything. The worst thing that could happen is that there is no abort and your program continues with faulty data. The best thing that can happen is that the memory location is not part of our program and we get a segmentation fault. That one has happened to me, yep in one of the probs for lab 7. It happened twice. Luckily the mistakes were silly and I was able to spot them with the help of the prof and a friend just in time!

Segmentation fault means you are accessing (or trying to?) memory that is not allocated to your program.

There are two ways to initialize your array: sort hand notation a[number]={value} I guess this only works if you wanna initialize it to all with the same value. The other way is the long notation where you go like this:

a[0]=value;

a[1]=value;

a[…]=…;

The best way to initialize an array is using default values!! Like this one for the chars {”}.

Wherever you can use a variable you can also use an indexed variable. So we can use arrays as function arguments! You do the array parameter like this type name_of_func(type(of arr) arr[]) You NEVER use the size on a one dimensional array. But if it’s a 2D or any other #D different from one then you go like this, 4D for example: type name_of_func(type(of arr) arr[][10][9][4]). For some reason you don’t write the first size but you gotta write the rest. I think this has to do with the things the compiler needs to know about the program at compile time.

Then when you call the function you simply do this: name_of_func(arr) You do NOT use the brackets when doing the call. Got it? lol~

So what is really passed with an array parameter? The base address. Addresses are complicated things… For example the array a is a variable that holds an address and that address will be the address of a[0] then the next index has a different address which is the address of a[0] plus(+) something, an amount that has to do with the number of index but is not for example 1 if the index is one. It’s something related uh not sure what it was. Gotta ask the prof to repeat that for me because you know I have deals… He explained that in class but u know how it goes with me… I’m like the dumb one in class lol… 

So um you know how I said earlier that the value of the array changes as a result from what you do in the func? Because they’re similar to call-by-ref? Well if you don’t want that to happen just add const before the var type. Const only gives you read acces. Oooh!! That sounds like those annoying “read-only” files, gurrr.

So wow, I remember this one day the prof was talking about the right way to round something up but I’m not sure what this something was I’m pretty sure it had to do with arrays but anyway the right way to do this thing is like this:

static_cast<int>(floor(number+0.5));

Now let’s take a break from class to complain and adventure! Complain: My back hurts like hell, ouch!!! WOOO 😦 Don’t know why??? 😥

Adventures:

I wanna thank all these people who recently became my followers! Yay! 

Image

Image

Image

Anyway this is it for today I’ll write more tomorrow I’m ultra tired! Thanks everyone!!!

 

The Competish

Well, well! I just got back from Bayamon! Today was the competition and it was soooo much fun!!! Hahaha!! Yeah that programming competition I mentioned a loooooooooong time ago. The day finally arrived and now it’s over!!! I’m glad I went. I learned a lot and I met a lot of cool people! I did not win of course! And of course I was not expecting too. A lot of things happened. Expected ones and unexpected ones. The expected ones: me=not understanding the problems. Unexpected ones: me=relaxed. Not freaking out about not knowing how to solve the problems. I think this was because I’ve only slept 4hrs so I think that well if I usually can’t concentrate imagine how I felt today………. hoho. Nah it must be because I knew I didn’t stand a chance. I hate freaking out so feeling the way I felt during the contest was actually kinda cool~~~ SOoOoO strange~~~ Hahaha. Another unexpected thing was that they didn’t have emacs so I ended up using Visual Studio. I learned a little, yay! And now I wanna practice more on it. Another unexpected thing that happened was that I was happy and thrilled all the way until after lunch. After lunch they ruined the WHOLE THING!!!!!! How? With a whole bunch of boring talks about this and that and at that moment my mood also started changing and I WANTED TO LEAVE!!! But I think it’s because I never really go anywhere at all so when I go somewhere and don’t hurry up and come back I get so ANXIOUS! But I also have my 3rd Phys Chem test on Tuesday and I’m super pissed @ myself because I didn’t drop the darn class. I HATE it. >:o But I don’t hate chemistry. I actually ♥ it. I just hate the fact that there seems to be so little opportunity on it. Which is why I’m thinking of changing to comp. But I don’t want to make a rash decision so this is the plan! I’ll only take comp classes next semester without actually changing my dept. It’s funny because back when I was young I did an Associate’s degree on drafting but while I was doing it I didn’t feel like it, I wanted to study computer science but since the drafting thing was only 2yrs I was like eh I’ll finish this. But then when I decided to come and study here(last semester lol) I was planning to study computer science but then at the last moment I changed my mind I chose chemistry and now I just wonder how did that happen? Why am always changing my mind? Ugh…

But alas! Nevermind my life drama! Trollolololololololol! Sorry that I complain so much!! Check this out!!! Me w/ all the cool people I met!!!! Yaaaaaaaaaaaaaaay!!!!!!!!!!!! These dudes made my DAY!!!!!!!!!!! They are hilarious!!!! 

I’m the extremely tiny person!(BTW I’m female, I just kinda look like a little boy for some reason. lol. Everyone always tells me that I remind them of their lil’ bro and today when one of the kids won (there was a category for kids too) one of the dudes was like: he looks like you and I’m like: “been there” lol the kid DID NOT look like me I think the guy was just messin’ around… A lot of “been there” things happened today. These guys made me feel like back in the day. So cray.)

Image

 

Oh and here! Random people programming, you know doing there own thing! (All these pics are from their fb pg)

Image

Wooo!!! I look So creepy in this PIC!!! Whaaaaaaaa!! Why did they do this??? My prof is in this pic too!

Image

WHAT? MORE ME??? They only posted 9pics on their fb and I’m in 3?!?!?! WHAT IS THIS?!?! Stalkers, lol. Yay I’m famous!lol

 

Image

Well I’ll be writing more eventually because I gotta go do stuff! Anyway I’m grateful we had this competish it made me feel more like: “Hey I have a life!”

Virtual box NIGHTMARE!

So many bad things happened during these unblogged days. ARGH!!!!!! URGH!!!!! Ugh!!!!!!! THE PAIN AND MISERY!!!

I got a freaking 72%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! On my last midterm!!! I MESSED EVERYTHING UP!!!!!! This is ALL BIOLOGY AND ORGANIC CHEMISTRY AND THE BIOLOGY lab’s FAULT!!!!!!!!!!!!!!!!!!!!!!!! Why did I have all those tests TOGETHER!!!!!!! So UNFAIR!!!!!!! Woooooo…. So u can imagine that my other grades… not that good either because I ended up studying a little bit for each… I got a 93 on the lab test and an 86 on org chem as for the biology class one I have yet to know my grade. This is horrible!!! I’m the worst!! I got a 68 in Food Chem and a 68 in Phys Chem. Why?!?!?! Since when??? Is this a loop???

#include <iostream>

using namespace std;

int main()

{

while(shirley=mayaguez){

shirley=bad_grades}

shirley=never_gets_a_job

return 0;

}

Aside that, I’ve been into not leaving as much white space as I used to in my prgms because the prof said it wasn’t a good idea and I was like: Uhhhhhh! But then I thought about it and decided it was better that way because long prgms full of white space can get on my nerves too!! 

Now the other horrible thing was lab 6. BAD THINGS. BAD THINGS.

Prob 2 was a sweetie. Prob 1 gave me average trouble but I made it a little bit messy. But the rest were almost impossible and I couldn’t go to the prof’s office because we had no class and I started this thing seriously late sooo my friends ended up explaining a whole bunch of things and I read chapter 7. Because prob 4 and 5 were about arrays and I knew nothing about arrays now I know fors and arrays are best friends and nested fors are even more best friends w/ arrays. However, I don’t think I ever understood the way you add in a hexadecimal way because my result was definitely not the same as the one I would get w/ a hex dec calculator. The third one ran but I never got it to do what I wanted it to do. As for prob 5 I wanted to fix it because the thing is that the prof gave an example on the instructions where the array was already initialized but the book shows you the way for the user to input what he wants on the array. My problem has the array declared but then I thought I should fix that. By fixing I mean I should eliminate the initialization and let the user input the values for the array because that’s basically how prob 4 works too, user enters stuff, but then I said forget this I’ll concentrate on fixing prob 3 and 4 so I wasted all my time and suddenly it’s 11:47pm, the lab expires at 11:55pm. So I told myself you did what you could. Submit it already before it’s too late. Guess what? The internet on my virtual box wasn’t WORKING!!! And I can’t c/p to windows!!!! I already knew the internet wasn’t working and I had previously asked Emmanuelle how to fix it but he was like: I’ll fix it I don’t want you to ruin something. So u know I was like, o.k. But I hadn’t connected the dots until the last minute!!! I can’t submit w/ out internet!!! So at the MEGA last minute I ask Emmanuelle again but he’s like I can’t tell you if I’m not looking at it. Because he doesn’t have virtual box he has partial install which is what we wanted to do on my computer but we didn’t know how so we ended up installing the box. But the thing is I had to re-write everything in word!!! And WORD IS NOT AN EDITOR!!!!!!!!!! Plus it changes EVERYTHING to caps and junk!!! Who knows all the mistakes it has! I had to re-submit 3 times because I kept finding errors!!! So I don’t know if I’ll just get an F or what because I consider 3/5 are faulty and who knows maybe all 5 problems are already faulty but to top it all off and submit a word document, really?!?!?! Wooooooo~~~~. Pff and now I was going to show you the massage firefox was giving me but now suddenly firefox works and has a google bar that it didn’t use to have!!! WHAT THE HECK?!?!?!?!?! HAPPENED?!?!? I got trolled by my box. Sunday was the worst I ended up submitting 3hrs late anyway!!! Because I had to re-write everything. I HAD NEVER SUBMITTED LATE and I wasn’t planning.

But anyway now I’ll have to make up for it by doing COJ probs!!! And starting w/ lab 7 asap… 

So anyway Monday before the test is the only class I have yet to blog but guess what? We only did th practice test that day so I don’t have much to say so I’ll just talk about arrays. 

An array is like a variable that stores more than one variable and you do things with it like sorting! Which is basically what problem 3 was but it didn’t tell me to do it w/ arrays so kept trying w/ whiles…. So when you have an array you need to give it a type, a name and a size. You don’t have to fill the whole thing and Emmanuelle taught me that I can initialize them w/ defaults (this one’s for chars {”}) so I won’t have a problem with garbage. But arrays are awfully complicated. Sorting is hard because it needs so many functions or at least the algorithm presented on the book is like that. I’m starting to get confused w/ the word algorithm I feel people call everything an algorithm. I thought the algorithm was the sequence of instructions in English but people call algorithm to the sequence in C++ too.  

**Oh! Guess what I learned a few minutes ago? That you can actually save COJ problems in PDF!!! Useful~

That’s all I’m going to say for now because I gotta go… But before I leave I will thank all of you again! I got two more followers! Whee!!!

ImageImage

Thanks GUYS!!!!!!!!!!!!! Bye!!!

P.S I recently remembered that Ada is a programming language and now I’m all about wanting to learn that one!! Just because I look up to Ada Lovelace!!! I think it must be beautiful!! I also discovered that I should get to learning php if I ever want to start making websites. I also realize that if I have so many programming dreams I should just drop Chemistry because I feel SO TROLLED by it!! lolololololoolloolololollol!!

Notes and adventures after March 17th!!! ☺☻

Hello everyone! Once again I got three emails that made me smile!!! I have two more followers and I got a like on yesterday’s post! Hooray! Everyone’s so interested in my Comp3010 adventures! Thanks for your support everyone! I’ll try my best to get an A on this course and to continue to write posts!☺♥☻

ImageImage

Image

So now I’ll start with the notes from my second notebook. All the first comp pages are full of pseudo code and code of that EVIL LAB 5!!!!!!!!!!!! I will show you some of it.

ImageImageImageImage

Something important that I learned while doing lab 5 is that if it’s a void function you can’t assign it to other variables because it doesn’t return a value. Lol. Yeah… I was trying to do that for one of the problems… Teehee…

So in one of our classes we talked about debugging but I promise you debugging is NOT MY FORTE!!!!!!! That STUPID debugger! It’s so confusing… But I actually used it a lot to see if I could figure out the mistake on my loop in problem 5 so we became frienemies. However I still have trouble getting its essence….. Blaaaaaaaugh….. But check this out, something weirderer happened. The prof told us that one way of debugging was this:

Int main(int argc, char **argv){

}

W0W! I have no idea how to use that and there were a lot of things that I didn’t understand when he was explaining it but I admit that day my head was up in the clouds so I felt super ashamed and didn’t feel comfortable asking anything else. But because I did ask things the prof ended up telling me to look these two things up: unit testing and test driven development.

I’ll do it right after I tell you that I just remembered what all that command stuff above is. Well it’s this REALLY interesting thing where when you’re going to run your program you add some words and it runs some tests. The prof ran all those tests and all for in class but because I’m like that I didn’t get much of what was being done…….. I feel terrible now… Anyway if you want to make it work you have to let the compiler(?) know how many words will be added. But anyway I have this other thing written on my notebook:

Int main(int argc, char **argv){

If (argc >=2)

}

I think this is how it is done but I’m not sure. MUST ask about it later….

O.k so unit testing, I just looked it up on C++ reference we have but on the search bar so what I’m going to say was taken from a forum which means it could be right or wrong! Acc to what I just read unit testing(which makes sense) is when you test each function as a standalone function. Well that makes sense and that’s what I was doing every time I did a driver program. So I guess when you do a driver program you’re doing unit testing. It all makes sense now~

Test driven development is a cycle where you right a little bit of code test it and so on… Didn’t get it very well but I get the feeling it’s similar to unit testing.

O.k! Now we start w/ chapter 6, Mr. Complicated. Ugh…… Things are about to get UGLY mind boggling. O.k Let’s begin by defining a class. According to my notes, classes are subsets of types. In other words classes are types. And every object is a variable. But a variable is an object if its type is a class… I feel like I need a flow diagram, eesh…… But anyway according to what I read in the book an object is a special kind of variable that has it’s own functions attached to it. Cool!

By now I’ve learned that a stream is a flow of data and its value is a connection to an existing file. So there are all kinds of stream and it can be input stream(comes from keyboard or file) or output stream(goes to screen or file).

So anyway I/O stands for input/output and guess what? Cin anf cout are STREAMS! That’s why we use the include directive <iostream>.

I have here that a stream object is a description of the file to which it is connected to, hmmm……

We also learned about a new include directive, <fstream> we use this one when we want to use streams that connect our program to external files. If you want to do that then you need to declare your streams just like w/ normal vars. But these streams will be type ifstream, ofstream, istream, ostream, etc…

Image

So sometimes instead of returning you’ll want to exit. So instead of typing return(0) we type exit(any other number different from zero). For example we use it when we want to test whether our file failed to open!

So we learned a lot about connecting files for output and input and what not and then we moved on to learning about width! Width was a fun topic. It’s basically for leaving spaces and aligning. For example you can do this:

Out_stream.width(4) if you have 3 numbers that you want to output they will be one space to the right… something like that… But guess what if we have 5 # the entire output will be printed and you basically accomplished nothing with width.

Remember how we would use .setf for the decimal pt and all that? Well guess what?! There’s unsetf too!!!!!! OOH! And guess what I learned that I found super interesting?! If you want to output a random number that was part of nothing just random output because it’s a number it doesn’t need quotations. I know quotations are only for text but it’s just that I thought random numbers counted as text too. But they don’t.

We also learned about setfill but my mind was wondering so I ever really got what it was for so I’ll ask the prof later. But in the mean time I found this at the reference:

/*unspecified*/ setfill (char_type c);

Set fill character

Sets c as the stream’s fill character.

Behaves as if member fill were called with c as argument on the stream on which it is inserted as a manipulator (it can be inserted on output streams).

This manipulator is declared in header <iomanip>.

Now I’ll talk about characteristics of things:

Image

Setf’s are sticky in the sense that it has effect until you unset it or do something that overwrites it.

Width is nonsticky

IMPORTANT! Streams are always passed by reference! But why? Well I’m not sure but the prof said that would be a test question so I better hurry up and figure it out. I’ll tell you what I think the answer is.

Well first of all, if we want to pass something by reference or by value it must mean we’re using it in a function, right? So if I’m using a stream parameter it has to be called by reference because a stream’s value is a connection to a file and its contents could change and we need them to complete running the program. Call-by-reference parameters allow us to change the variable used in the function call. Not only that, but a stream is a variable which is what an argument for call by reference must be. Anyway when we pass a stream we’re doing something that we’ll get us either output or input and at least to obtain input values we need to change the variable so there we go. I wonder how much I would get w/ this answer?? Gee…..

SO um now we go on to get functions which I don’t get at all the only thing I know is that they don’t skip over whitespace but even so eeeh? So the extraction operator actually does skip and junk, yeah. Blah… I feel like I’ll FAIL! DAAAAAMN IT!!!!!!!!!!!!! Tears++ lol!

 

Oooh! Good news! I just got another email with another follower: Ta-da!!!

 

Image

 

Anyway this is it for today! Must go do lab 6 and practice test! ☺♥☻. BYE!!!!!!