Assuming that you are just being vague on your homework question, and the requirement is to print a string N characters long, where the first is a '+', the second is a '-', the third is a '.', and the pattern repeats from there ...
This isn't difficult, you just need to think about it.
Start by setting up a
for
loop to print N characters - make it always print a '+'. Run it, test it, fix it if necessary so it works for any value of N you can think of!
Then add a counter that starts at zero outside the loop. Inside the loop, replace the '+' with printing the value of the counter and increment teh counter each time you print. Run it, test it ... you know the drill - you are looking for an output like "012345678910111213..."
Now modify the loop so that it also resets the counter when it gets to three. Check that it now prints "012012012012012012012..."
Now replace the print with either an
if...else if...else
or a
switch
block (depending on where your course has got to) to print a character based on the value of the counter: 0 prints '+', 1 prints '-', 2 prints '.'
Run it, blah, blah. Does it work? If so, that's your task done.
It's a "trick": breaking the code up into smaller bits you know how to do.
This may help:
How to Write Code to Solve a Problem, A Beginner's Guide[
^]