Now, I’m going to talk about how I wrote my codes for the Quiz #2. First, let’s check out the instructions:
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.
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.
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.
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.
.
Alex H.
Quiz #2 by alexhfoo is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.