For this quiz we had to create two programs.

In the first one we had to write a function called superpower that has two parameters of type long and returns a long which is first parameter raised to the power of the second.

For example, superpower (3, 4) would return 81.

And in the second program we wrote a function called stars that has one parameter of type int and prints (the function does not return anything) that many stars on a single line followed by a end-of-line character, so if we call the function with stars (5), the function will print like this:

*****

At first it was hard to write this codes but then, when I looked for help I could notice that actually they were pretty easy and with a few minutes of reading I could understand a little bit more about how the functions work.

Here are the codes of my two programs.

SuperPower!

#include <iostream>
#include <cmath>

using namespace std;

long superpower (long a, long b){
  long superpower = 0;
  superpower = pow(a,b);
  return superpower;
}

int main (){
 cout<< superpower(3,4) <<endl;

 return 0;

}

Stars!

#include <iostream>
using namespace std;

void stars(int iStars){
  for (int i = 1 ; i <= iStars; i++){
    cout << "*";
  }
  cout << endl;

}

int main(){
  stars(5);
  return 0;
}

CC BY 4.0 Quiz #6! by esaupreciado is licensed under a Creative Commons Attribution 4.0 International License.