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
Omar Peza’s Articles at TC101 Fall 2015
Introduction to Programming Python and C++

Author Archives: Omar Peza

Final Project

We. Are. Done. Finally, our program works like a charm, after several days of research and hardwork, our project is capable of resizing an image and changing the color to black and white. 

We kinda did it in two parts, the first one being the black and white, that you can check out here.

For the “second part”, we researched and found out how to resize the source image using math and arrays. These links were reaaaaaally useful:

http://stackoverflow.com/questions/27351737/c-how-to-shrink-an-image-using-a-pointer-array
http://stackoverflow.com/questions/299267/image-scaling-and-rotating-in-c-c
http://doc.gnu-darwin.org/ImageMagick/www/ImageMagickObject.html
http://www.cplusplus.com/forum/general/2615/

We kinda teamed up with Eduardo, we worked together, and mutually helped each other. 

We had a lot of errors during the process about syntax but one we dealt with the most was an error called “segmentation fault”. After battling with it, we found out that our program wasn’t the problem, but the source image was. We looked and tried several images until we found one that worked, which was the golden retriever puppy on the English Wikipedia page of puppies. Eduardo told us that this picture didn’t have the same error and we confirmed that it didn’t.

We are really happy about the outcome of the project.

Here are some screenshots:

You can check out our final code here:

https://github.com/kenwbauer/TC101F15_Team06/blob/master/FINALPROJECT.cpp

Mastery 25

On this mastery I’ll show you what are strings and how to use them in C++.

String are things that are represented by a sequence of characters.

We will create a function that works as a palindrome and tells the user if the word he input is a palindrome or not. Do as follows:

  1. Create a main program and leave a space before it for the function
  2. Create a function of type string called palindrome
  3. Condition the user input with VARIABLE.rbegin and VARIABLE.rend. This iterators make the string return reversed to the beginning and end. This is the Palindrome “function”
  4. In main(), ask the user for the input and call for the function.

Your program should look something like this:

Now let’s test it:

Great! Now you know how to do a basic program using string. If you want to learn more about strings, go to this webpage:

http://www.cplusplus.com/reference/string/string/

Mastery 2

On this mastery I’ll show you how to program in an online compiler and how to run your program in the same online tool.

There’s an online compiler and debugging tool called Ideone, which allows us to code online and then test it right there. So, go ahead and open ideone.com

Once you opened the webpage, something similar to this will appear on your screen. On the centre of the webpage is where our programs are written, On the bottom left , we have the language of the source code (which can be changed) and on the bottom right we have the run button.

Let’s create a “Hello World” program and run it:

As you can observe, our program was successful and it did output the desired outcome. 

Now, just to have fun, let’s see what happens if our program has a mistake:

This online tool is great, and now you know how to use it. Congrats!

Matery 22

On this mastery I’ll show you when to use what type of repetition in a program. 

For the purpose of this mastery, we’ll focus on while and for loops because they are the easiest and most used ones.

On mastery 19 we learned how to use a while loop. The while loop consists of something that will happen WHILE a condition is given. For example: WHILE x is greater or equal than 0, something will happen, and this process will continue to happen WHILE this condition is true.

On mastery 20 we learned how to use a for loop.

A FOR loop is a type of loop which allows you to give specific conditions to it, and then repeat when this conditions are true.

Now, while and for may be seem like they are the same, but they certainly ain’t. The main difference between them is that FOR loops will continue happening for a given number of iterations. 

As you may recall, functions often use a for loop because of the iteration part. In someway, FOR loops are “better” when dealing with functions, while WHILE loops are great to work with inside main().

Picture and more information from this webpage.

Mastery 17

On this mastery I’ll show you what and how to use the conditional switch in C++.

Switch is a statement that tests a variable for equality in a list of given conditions. It is somehow a summarized version of IF when you have a lot of conditions. 

This flow chart may help you understand better, and this webpage too:

The default syntax of switch goes like this:

switch (expression)
case “condition” : outcome
[default:statement]    //This is used when the variable input isn’t a valid option.

So, for the purpose of this mastery, lets create a program were the user can input his points on masteries so far and tell him if his good or screwed. Do as follows:

  1. Create our “basic” program.
  2. Inside the int, declare a char variable with an assigned value.
  3. Use switch to condition the outcome and tell the user if his good or screwed.

Your program should look something like this:

Now let’s test it:

Let’s just play with another value:

Great! Now you know what and how to use switch conditional.

Mastery 8

On this mastery I’ll talk about coding conventions on C++. 

Coding conventions are just a set of “guidelines” that talk about the style to format a code. For example, how to correctly use braces, commas, comments, capitalization, etc. You can read a lot more of these “rules” in these webpages:

https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Style_Conventions

https://gcc.gnu.org/wiki/CppConventions

Since masteries 1 and 7 we’ve been using the correct style and format. If we weren’t, we could’ve just written all our codes in one line instead of multiple lines, for example, tell me how do you prefer to read a code, like this? ->

Or like this? ->

Which one is easier to read?

And know you now why there are coding conventions: to make everything look nice and easy to read.

Survival guide for TC101

Here’s a brief video of me talking about my experience with the class and some tips and tricks to it.

Video.

This isn’t a clever titleThis WSQ was not as hard as I thought,…

The Killers

This isn’t a clever title

This WSQ was not as hard as I thought, but it required research and a full understanding of what was inside the text file. I checked these webpages, I think they are useful:
http://www.cplusplus.com/doc/tutorial/files/
http://www.cplusplus.com/forum/beginner/8388/

And you can check out my code here.

1as7 one

image

Last WSQ of the semester, I can’t explain how fast it went!

I found Scilab as a very useful tool since it can do many things simultaneously. You have a text editor and it also graphs! It is indeed amazing and I know it may be useful in the near future for the career. 

Project

Today Ale and I finally did some serious advance in the fina project. We did a lot of research and we were able to run one part of the project, modifying the image to black and white. Here are some of the webpages we used:

Basic command-lines:
http://www.imagemagick.org/script/command-line-tools.php
http://www.imagemagick.org/script/command-line-processing.php

Convert input image to b&w/grayscale: 
http://www.imagemagick.org/script/color.php
http://www.imagemagick.org/script/color-management.php
http://stackoverflow.com/questions/13317753/convert-rgb-to-grayscale-in-imagemagick-command-line 

And that’s pretty much it. We will try to finish the project by doing the “second part” about resizing the image tomorrow. In the meantime, you can check our code here.

P.S. Here is how it’s shown in Ubuntu:

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).