Help please?

Hey guys.

I have a challenge for class and I'm stumped. It's very simple but I just can't seem to wrap my head around it. We must make the serial monitor print this:

**









without using serial print a bunch of times.

I know it involves nested loops but I just can't seem to grasp how to program it.

Can anyone point me in the right direction and offer some guidance?

Thanks in advance,
Mike

You can actually do it in one line of code using a single print statement :slight_smile:

Were you told that you have to use for loops ?
Don't forget that the loop() function does what it says
How many print statements are you allowed to use ?

We just can not use print 10 times to achieve this.

It says to use two nested loops instead.

I’ve thought about and tried for loops, if’s, etc. - and just can’t seem to get it.

Not sure if I’m overthinking it, or just can’t grasp the idea; however, any help would be greatly appreciated.

Thanks,
Mike

You have been told how to write a for() statement, yes?

for(int x = 1; x<=10;x++) {}

The numbers in the statement don’t have to be constants like 1 or 10 - they can be expressions using other variables defined outside the statement itself.

Yeah we've learned for loops. Not thoroughly. My course is very basic and hasn't done a whole lot of in depth explaining, picking code apart line by line. A lot of copy/paste, with a little explanation.

I just can't seem to wrap my head around setting the for loop to compare to another variable, haha.

Oy, my brain atm :o

My course is very basic and hasn’t done a whole lot of in depth explaining

For the stupidly simple things, you ARE expected to experiment and RTFM.

What does

   for(int row=0; row<10; row++)
   {
      for(int col = 0; col < row; col++)
      {
          Serial.print('*');
      }
      Serial.println();
   }

do for YOU?

Can you see what you need to adjust to get the right number of rows?

Can you see what YOU need to adjust to get the right number of columns per row?

Can you see that MEANINGFUL names make a lot more sense than i and j?

 Serial.println(F("*\n**\n***\n****\n*****\n******\n*******\n********\n*********\n**********"));

Will not teach you anything about for loops, of course !