Quiz #2

Now, I’m going to talk about how I wrote my codes for the Quiz #2. First, let’s check out the instructions:
Captura de pantalla 2016-02-11 a las 17.55.39

I started with the first program and it took me the whole class because I was having problems with the structure of the code. I asked my friend Dario to help me and he told me what I had wrong. Thanks m8. You can visit his blog here, he has a lot of cool stuff there. He is Dario, in case you didn’t know him hahaha.

djafj.jpg

So here is the code for my first program…

As you can see, I created a function called “superpower” and inside the function I put a loop, so I could raise the first parameter to the second one. This loop would keep working if the value of d was different from the second number.

Captura de pantalla 2016-02-11 a las 18.11.56.png

Once I figured it out that part, I wrote the main function and just called the superpower function when I was supposed to give the answer. I used another loop just to let the user try with different numbers.

 

And for the second program was easier. For this one, the user had to type a number “n” and then the program had to display “n” times the character ‘*’. I created a function called “stars” and put a loop which only write “*” times as the user asked for. Then, in the main function I just called the “stars” function as the answer. This one was easier though.

Captura de pantalla 2016-02-11 a las 18.20.35.png

I’m feeling lazy right now so this time I won’t be uploading a video of my codes working, but you can check them out on GitHub.The files are called “pro1Quiz2.cpp and pro2Quiz2.cpp”. Here is the link. Feel free to comment or try them on your own way.

5nczoumgibjzo
24294566811_7004231734_k

Continue reading “Quiz #2”

Quiz #1

My first quiz… Let’s start reading what I was supposed to do… 

Captura de pantalla 2016-02-09 a las 11.50.01.png

I had some trouble trying to get the value of π, I did some research and I needed the <cmath> library because I was going to need the value of π. As you are using the cmath library, π is declared as M_PI so you just have to type that when you will use π.  After that, the rest of the program was very simple.

Here is how I wrote my code for the program #1. 

Captura de pantalla 2016-02-09 a las 12.08.02.png

The next program was pretty easy. I was asked to write a program which the user could type two numbers and the program would show the product of the two numbers, the division and the remainder from the division of the two numbers. You shouldn’t have any problem writing this code. Here is how I wrote the program #2.

Captura de pantalla 2016-02-09 a las 12.11.35

And finally, for the last program the only thing that you needed to change was the data type from int to float. You wouldn’t have a remainder from the division, you only were supposed to show the addition, product, subtraction and division of the two float numbers. Here is how I wrote my code for program #3.

Captura de pantalla 2016-02-09 a las 12.17.21.png

Here you can see my codes on GitHub. And here you can see my code working via ScreenCast.

Captura de pantalla 2016-02-09 a las 12.37.48.png

·Factorial calculator· #WSQ09

 

 

This one was a bit interesting and funny. I wrote something similar in my C# course last semester, so I had the idea of the logic of the program. After trying for a while, it finally worked and it was amazing…but I still was having a problem… the main loop didn’t work :/ so the question of “Would you like to type another number?” was useless.

At first I thought I confused the order of the loops but that wasn’t the problem. My friend Christian saw my code and we were trying to figure it out what was the problem… and finally we discovered it……. I used the variable “answ” as int and not as char… hahaha here is some advice for everyone: Make sure you have declared right you variables so you won’t be having any problem as I had!

Captura de pantalla 2016-02-03 a las 12.29.07.png

Here is a screenshot of code, also you can find it on GitHub if you want to download it and trying to make some changes, feel free. Link.

Captura de pantalla 2016-02-03 a las 12.31.53

I recorded a video of my code working with Jing, that is an awesome app which allows you to record whatever you are doing on your computer… Here is the link of my code working via ScreenCast.

Captura de pantalla 2016-02-03 a las 12.49.47

Alex H.

 

24294566811_7004231734_k
Another Sunrise over the Alps by Rogg4n Link on Flickr: https://www.flickr.com/photos/128294308@N05/24294566811/in/explore-2016-01-14/

·Sum of numbers· #WSQ07

For this program I had to use an if and a loop. The use of “if” was in order to make sure the user would not screw it up with the order of the numbers. At first I couldn’t figure it out the main logic of the program but then I had a moment of inspiration haha and here is the result.

Here is a screenshot of my code. Also you can check it out on GitHub. Link.

Captura de pantalla 2016-02-02 a las 12.38.34

It is important to keep in mind that the user won’t do exactly what you want, so you should always be prepared for the unexpected things.

And here you can see a video of my code working on ScreenCast…. Link

Captura de pantalla 2016-02-02 a las 22.57.19.png

I will be publishing all the WSQ’s soon and I hope it would help others. 😀

Alex H.

24294566811_7004231734_k
Another Sunrise over the Alps by Rogg4n Link on Flickr: https://www.flickr.com/photos/128294308@N05/24294566811/in/explore-2016-01-14/

 

·On to functions· #WSQ08

And now, we were supposed to be able to call functions and learn how to use them. For this program, the functions didn’t help a lot but if you have a more complicated program, they could be really important. I had to look for how to use them. Also I asked some friends who have already passed this course.

Here is a screenshot of my code, also you can see it on GitHub. Link GitHub. As you can see, I’m recording more videos of my codes and all that stuff, I find it very useful when you’re not able to take a screenshot of the whole code. Here you can see a video of the whole code on ScreenCast.

Captura de pantalla 2016-02-02 a las 23.25.25

Captura de pantalla 2016-02-02 a las 23.25.36.png

As you can see, the default function is main but you can call other functions and write different things in each one, giving a range of values. Then in your main function you call the other functions, for example “int difference” and it is supposed that it will print the difference between the two values given.

And if you click here, you can see a video of my code working via ScreenCast.

Captura de pantalla 2016-02-02 a las 23.26.46.png

Alex H.

24294566811_7004231734_k
Another Sunrise over the Alps by Rogg4n Link on Flickr: https://www.flickr.com/photos/128294308@N05/24294566811/in/explore-2016-01-14/

·Pick a number· #WSQ06

I had the task to write a program which could use a random number between the 1 and 100 and let the user play a game trying to guess that number. First of all, I had to look for how to print a random number. Honestly I didn’t save the pages where I found the information but if you type it on Google you won’t have any problem finding the libraries and the commands to print a random number.

Then I used a loop, so the user could keep guessing the number that the program had selected as default. Also I used a counter which would tell the user how many times he had tried guessing the number.

Here is a screenshot of how I wrote the program. Also you can find my code on GitHub. Link.

Captura de pantalla 2016-01-22 a las 18.39.31

Captura de pantalla 2016-01-29 a las 12.24.35

You can see a video of my program working on ScreenCast. Link.

Captura de pantalla 2016-01-29 a las 12.25.18

Alex H.

24294566811_7004231734_k
Another Sunrise over the Alps by Rogg4n Link on Flickr: https://www.flickr.com/photos/128294308@N05/24294566811/in/explore-2016-01-14/

·Temperature· #WSQ05

Welcome back! Now, I “decided” to write a program who can help anybody to convert a temperature in Fahrenheit to Celsius which it is very useful. First of all, I had to look for the formula in order to know how to convert any temperature from Fahrenheit to Celsius which is this one: C = 5 ∗ (F − 32)/9.

Then, I started writing the code asking the user to give a temperature in Fahrenheit, so the program could convert it to Celsius and tell her/him if the water boils at that temperature.

Here is a screenshot of my code and also you can find it on GitHub. Link

Captura de pantalla 2016-01-25 a las 0.35.06

And here you can see a video of my code working: Link

Captura de pantalla 2016-01-27 a las 13.23.05.png

 

Alex H.

24294566811_7004231734_k
Another Sunrise over the Alps by Rogg4n Link on Flickr: https://www.flickr.com/photos/128294308@N05/24294566811/in/explore-2016-01-14/

·Fun with numbers· #WSQ03

Well, another homework… haha just kidding. I’m learning how to improve my codes and all that stuff. I started reading some articles and looking for examples in c++, as I said previously, I didn’t remember how to write in c++. I spent a time exploring this helpful page. There a lot of tutorials in c++ and references.

Captura de pantalla 2016-01-22 a las 12.03.43

After reading for a while some tutorials and articles, I decided to start writing my code. My objective was to create a program that given two numbers, it could calculate different operations. I looked in some of my classmate’s programs in order to remember how to write all de cout and cin stuff.

And here is the result, after a few mistakes and trying to figure it out what was wrong, my program was finally running!

Captura de pantalla 2016-01-22 a las 12.16.38

And here is my program working in Terminal…

Captura de pantalla 2016-01-22 a las 12.18.30

Also, you can see my code on GitHub here

Captura de pantalla 2016-01-22 a las 12.20.30

Alex H.

24294566811_7004231734_k
Another Sunrise over the Alps by Rogg4n Link on Flickr: https://www.flickr.com/photos/128294308@N05/24294566811/in/explore-2016-01-14/

·Hello World· #WSQ02

After setting up my computer, I had the task of writing the basic code of “Hello World” in C++. The last time I wrote a code in C++ was when I was in high school so there were things that I didn’t remember at all. I had to search the basic commands for C++ and learn them again. After few minutes of writing, my code worked.

Captura de pantalla 2016-01-19 a las 11.57.21

 

Captura de pantalla 2016-01-19 a las 11.51.04

 

Alex H.

 

24294566811_7004231734_k
Another Sunrise over the Alps by Rogg4n Link on Flickr: https://www.flickr.com/photos/128294308@N05/24294566811/in/explore-2016-01-14/

Get coding #WSQo1

First I decided to download Atom because I thought it’s the easier one to work with in Mac. Here is the link from the Atom page, it is totally free for use. Link

Captura de pantalla 2016-01-19 a las 11.53.06

I installed correctly the program and everything was working right, then I just wrote the “Hello world” code.

Captura de pantalla 2016-01-19 a las 11.57.21

Then, I had to install the compiler, so I decided to use Homebrew, because it has packages that Mac doesn’t have and they let you compile files. Here is the link for Homebrew, it’s totally free for use. Link

Captura de pantalla 2016-01-19 a las 12.00.56.png

After downloading the Homebrew packages, I opened Terminal and typed the code that appeared on their webpage. Then you have to follow the instructions and type brew install gcc-g++ and you will have installed the compiler.

And that’s how I installed all the software and that stuff, now I can write in C++ and compile my files.

Alex H.

 

24294566811_7004231734_k
Another Sunrise over the Alps by Rogg4n Link on Flickr: https://www.flickr.com/photos/128294308@N05/24294566811/in/explore-2016-01-14/