15,999,229 members
1.00/5 (1 vote)
See more:
Here's the entire problem:

Write a function plot that will plot the values calculated by another function with rows of asterisks, each asterisk corresponding to the value 0.1. So 1 will be shown with a line of 10 asterisks, 0.5 with a row of 5 asterisks, 2 with a row of 20 asterisks etc. Pass the function that you want to plot as the first argument of the function plot. As an example of a function to plot implement the function sumSequence1(int count) that will calculate and return the sum of the first count terms in the sequence 1-1/3+1/5- 1/7+1/9... using iteration. For example, sumSequence(3) should calculate the sum 1-1/3+1/5, sumSequence(5) should calculate the sum 1-1/3+1/5- 1/7+1/9. As a second and third argument of function plot supply the minimum and the maximum values of count, for which you wand plot to call its first argument and plot the value returned. So if the first argument of plot is sumSequence1, the second is 3, the third is 6, your function plot should call sumSequence(3), sumSequence(4), sumSequence(5), and sumSequence(6) and print 4 lines of asterisks showing the values returned by each call. As a second example of a function to plot implement function sumSequence2(int count), which will calculate and return the sum of the first count terms in the sequence 1+1/3+1/5+1/7+1/9... using recursion, not iteration.

Tell me exactly what I gotta do and what it wants from me. I've been pulling my hair trying to understand this teacher's horrible directions.

What I have tried:

Reading the question, asking for teacher for help (he said to just read it again), haven't attempted it due to lack of understanding.
Posted
Updated 16-Apr-18 7:52am

## Solution 1

It's pretty clear if you just read it.
Quote:
Write a function plot that will plot the values calculated by another function with rows of asterisks, each asterisk corresponding to the value 0.1. So 1 will be shown with a line of 10 asterisks, 0.5 with a row of 5 asterisks, 2 with a row of 20 asterisks etc.

So you need to write a function called `plot`
It should plot the values calculated by another function with rows of asterisks
Each asterisk corresponding to the value 0.1. So 1 will be shown with a line of 10 asterisks, 0.5 with a row of 5 asterisks, 2 with a row of 20 asterisks etc.

So you need to either pass it a function pointer that returns a set of results, or the results themselves, depending on how far your course has got - check your last set of course notes and see what the teacher was discussing.

If you don't understand the rest of the directions, then talk to your tutor.

Comments
Member 13781304 16-Apr-18 2:47am
I know that part is clear but the part about sumSequence is what loses me. Please help.
OriginalGriff 16-Apr-18 3:39am
What part of it? It's reasonably clear to me, so I can't tell what part of the function description you are having difficulty understanding.

Remember that I can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with. :laugh:
CPallini 16-Apr-18 3:53am
At first don't bother about. Just write the plot function and test it. Then if you are still stuck ask for help about sumSequence.
CPallini 16-Apr-18 3:51am
5.

## Solution 2

Not a solution, just advices.
Quote:
I've been pulling my hair trying to understand this teacher's horrible directions.

There is nothing horrible in this requirement, just may be a little more complicated than usual.
In fact this requirement is nowhere as complicated as real life requirements. You just have to organize things, there is no trap, the whole requirement makes sense.
Quote:
eacher for help (he said to just read it again), haven't attempted it due to lack of understanding.

This kind of attitude is promising you hard days in future.
In fact it is a very sensible advice, when you don't understand something, read again, organize what you understood, and repeat when necessary.
When you are really stuck, ask for help on what you have difficulties.

As programmer, it is your job to analyze requirements and make sense of them. When something is inconsistent, expose the problem and ask for clarifications.

Comments
CPallini 16-Apr-18 16:38pm
5.
Patrice T 16-Apr-18 17:47pm
Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 Richard MacCutchan 50 Menci Lucio 35 Richard Deeming 30 OriginalGriff 10 CPallini 10
 OriginalGriff 521 Pete O'Hanlon 250 Richard Deeming 230 Dave Kreskowiak 133 CPallini 120

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900