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

.

5nczoumgibjzo

 

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/

CC BY-SA 4.0 Quiz #2 by alexhfoo is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.