Challenge accepted, Quiz 2.

giphy

Hello my friends. I had to mention that we made this quiz some weeks ago, and here is my post about it. I fell nervous when we made the quiz, but after doing my WSQ09 I learned how to use the for Loop and it safe my life. Also lynda (A platform where you can search for information about everything -www.lynda.com-). And if you want to learn more, I suggest to visit this page who helps a lot with C++ (and obviusly to make the programs of this quiz) http://www.cplusplus.com/doc/tutorial/control/ ; on this link, you can find useful information about the loops, who are always necesary, and here another link to understand the functions (I have to read it sometimes because I really get in trouble with it, but now I’m a master on functions ;D). The links:

http://www.lynda.com/C-tutorials/Creating-user-defined-functions/167922/181569-4.html

http://www.cplusplus.com/doc/tutorial/functions/

But well, let’s go to the important think, the quiz.

The instructions were:

1. Create a program with the following function. Write a function called superpower that has receives two parameters (ints) and returns an integer which is first parameter raised to the power of the second, which is to say it returns a b . There are many ways to do this, but the intent is for you to use a loop or recursion.

So to do that, at first, we have to use the function SUPERPOWER and inside of it, we have to do the operation (a^b) -I had a headache doing that- because it wasn’t too difficult but i had my for loop wrong so I had to start again and make it functional. So, here my code with some comments to make it easier.

spp

And the exe.

sppc

2. Create a program with the following function. Write a function called

sts
stsc
giphy-3.gif

that has one parameter of type integer and PRINTS that many stars on a single line, so if we call the function with stars(5), the function will print like this: *****

This program was easier than the another one, just making a do-while loop to print one star when the cycle repeats, in other words, print a star until the counter(the value that you declare as 0) as the same as the value that the user enter to the program. Obviusly dont forget to do the function stars.

My code:

sts

Running:

stsc

And dudeeee, it works.

giphy-3.gif

Dont forget to go to GitHub and check my codes!

https://github.com/eduardomrlsg/TC101/blob/master/SuperPower

https://github.com/eduardomrlsg/TC101/blob/master/Stars

I hope this will be useful for you guys,

Regards.

EdM

 

 

CC BY-SA 4.0 Challenge accepted, Quiz 2. by eduardomoralesg is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.