Author Archives: rohdzaimar

#Mastery16

#Mastery12

#Mastery11

Submit via Blog RSS and GitHub.

 

Submitting work via a Blog RSS is really useful. There are many sites that “read” RSS data on the web, and there are many sites that source the web with RSS data, such as twitter, withknown, myblog, blogger, etc… The purpose of having an RSS source, is that indepently from the RSS source program you are familiar with, any other RSS reader may receive information from this sources and direct the user to the source site. Ken uses this technology to revise all of our work very quick and easy. Every time you use a # (hashtag) on your blog, github or twitter, Ken´s site (Which is also an RSS reader) grabs the emission these hashtags and creates a pool of RSS files related to whatever kens decides to filter. In his case, he decides to filter anything related to Masteries, and WSQs. He knows not many other guys around will be submiting things with these hashtags on them, which makes revising our stuff pretty simple. To submit work through RSS you just need to enter any RSS source site (such as twitter or a blogging site) and submit work.

 

The important of this mastery is gitHub, which is a git repository hosting service where users may commit to repositories on the web and receive feedback from other programmers around. Github is also an RSS source site.

 

To use gitHub you need two things: a gitHub account on www.github.com , and to download a gitHub client for your computer, where you can link your local files to your repository on the web. In my case, i downloaded the gitHub Mac OSX client avaiable at: GitHub for Mac.

 

Once you launch the client you will need to set it up before anything else. A startup window will appear:

 

1: Click “Continue” to connect to GitHub and enter your GitHub credentials, and click “Sign in”. Once you’re signed in, click “Continue” to move onto the next step. 

2: GitHub for Mac autofills your Git configuration from your GitHub name and email address. Make sure that these are correct so that Git can correctly attribute all of your commits and then click “Continue”.

3: Select any local repositories on your computer. This means that you will need to link a folder with your client. Whatever put in this folder will be available to be commited onto your gitHub. Once you have commited a new file, click on sync, and your code files will appear online.

 

Hope this information works well for you!

 

cheers.

 

 

 

Babylonian Method

In numerical analysis, there are several ways of computing the square root of a nonnegative, real number. The most ancient method we know of is the Babylonian Method, which works using approximations. using a simple algorithm found at: http://en.wikipedia.org/wiki/Methods_of_computing_square_roots you can calculate a very accurate approximation to the square root of a number.

 

here is the link to my github code:

 

WSQ13.cpp

 

And this is how it looks:

 

 

As you can see, it is pretty accurate. I set the error to 0.00001 (1/100,000).

 

Greatest Common Divisor

Calculating the GCD is something we learn early in elementary school. Although we all are familiar with the term, many people is not familiar with an algorithm to calculate a GCD between two numbers. 

 

The eucledian algoritgth solves this problem quite well.

 

You can look this algorithm up in: http://en.wikipedia.org/wiki/Greatest_common_divisor

 

For I wrote a program that does this. I´ll add a link for my gitHub code down below and I´ll also paste a couple pics of my code working.

 

Cheers!

 

link —->   WSQ12.cpp

 

 

 

Lists (Arrays)

was about lists and working with arrays. I found a very useful site for learning pretty much any topic regarding c++.

 

Try: http://www.cplusplus.com

 

Here´s the link for my github code: WSQ10.cpp

 

Here is a pic of my code and one that shows how the program runs:

 

 

And Here´s how the program runs:

 

 

Factorial Calculator

 

For this WSQ, I programmed a factorial calculator. The program asks the user for a relatively small, positive integer, the program does the calculation using a “Factorial” function, designed with a loop, and later prints the value. After delivering the calculation, the program asks the user if they would like to compute another value. This is done using a simple logical while loop. 

 

The structure of the program still is pretty basic, but does need attention in the use of functions. 

 

Below i´ll paste a few pictures of both my code and the running program:

 

And here´s the running program:

 

 

On to functions:

For of my course, I learned how to declare a few basic arithmetic functions.

 

This is how they look like:

 

 

After declaring functions, you just need to call them in the main section and write the arguments, which are the two variables you want the function to compute.

At the end, the program looks like this:

 

 

Cheers.

 

Sum of range:

For of my course I programmed a very interesting program to understand the use of “for” loops, and to understand the increment operators and compound assignment operators:

 

The program sums every number in a range given by the user.

 

Lets say the user gave 1 as the first number and 10 as the second number. The program would do the following:

 

0+1+2+3+4+5+6+7+8+9+10=55

 

The program also compares the first and the last numbers and makes reacomodates the first below the last so that the range is correctly calculated.

 

I´ll post a picture of my code.

 

Here notice im using a “For” loop.

First i assing “counter” the value of “first”. This only happens when the loop initializes. Then, For “Counter” is less or equal than “last”, counter is incremented by one. And if the conditional is true, the code inside the loop runs.

 

Sum += counter

 

Which can also be written as: Sum = Sum + counter.

 

When the conditional is no longer true, the program exits the loop and prints the value of “sum”.

 

here it is how it looks on the terminal.

 

Cheers.