Function Help

Write the following 3 functions.

a) A function the prints three asterisks with three spaces in between each, starting in the first column:
* * *
Do not print a new-line in this function.

b) A function that prints the same three asterisks with three spaces between each, but with two blanks (spaces) at the beginning of the line.

c) A function that prints a new-line (and nothing else).

Using only calls to these three functions in the main program, print the following 15-line design:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
* * *
* * *
* * *

*   *   *
  *   *   *
*   *   *
  *   *   *
*   *   *

*   *   *  *   *   *
  *   *   *
  *   *   *  *   *   *
  *   *   *
*   *   *  *   *   *




So I am absolutely horrible at functions...
I was hoping that somebody could walk me through this, but please don't just give me the code. I would like to learn from this and be walked through the steps of creating this program. Thank you so much to anybody that is willing to help!

At this point I don't have anything besides some guesses on how to accomplish this. My first question is how would do i call these three functions to make the designs? Do I need to write the code so that I input maybe like 1, 2, or 3, and the one of the lines appear? How exactly would I start on this?
Ok, so since the functions won't be returning anything to the main function, they should be of type void. You can use std::cout inside those functions just like you would in the main function.

In your main function you would call the functions by name, for example if your had a function like this:

1
2
3
4
void hi()
{
    std::cout << "Hi!";
}


You would call that function in the main function like this:

1
2
3
4
int main()
{
    hi();
}
Last edited on
Topic archived. No new replies allowed.