15,942,580 members
See more:
```bbbb*bbbb
bbb***bbb
bb*****bb
b*******b
*********```

Posted
Updated 27-Oct-17 3:21am
v2
Richard MacCutchan 27-Jun-15 8:56am
Create a loop using the number of 'b's as a count to tell how many 'b's to print and how many stars. You can do it on paper first to see what the values should be for each line.

## Solution 1

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!

This isn't complicated: just try to think about how you would do it yourself, and set up two loops, one inside the other.

## Solution 2

This is the complete and correct solution:

C++
```//...
#include <stdio.h>

//...

puts("bbbb*bbbb");
puts("bbb***bbb");
puts("bb*****bb");
puts("b*******b");
puts("*********");```

Probably, this solution is more compact that you would expect to get with all your loops and variables. Isn't it not what you want? Then this code sample should teach you to ask questions correctly.

—SA

v2
[no name] 27-Jun-15 15:07pm
No, sorry this time you are wrong. the following is much more efficient:
puts("bbbb*bbbb\r\nbbb***bbb\r\nbb*****bb\r\nb*******b\r\n*********\r\n");
Sergey Alexandrovich Kryukov 27-Jun-15 15:18pm
Oh yes, I agree it would be more efficient code. But I never said that my code is the shortest or most efficient. I only said that it might be shorter than the code "with loops and variables". So, where I was wrong?

Besides, your solution has a problem, so it could not call it correct. Here is why: end-of-line characters depend on the system. It's not always \r\n. My solution is platform-independent, because the library works depending on the platform, and yours is not.

Are you agree now?

—SA
[no name] 27-Jun-15 15:25pm
Grrrrrrr yes I agree. I never said my code is platform independed! Anyway my small 5.
Sergey Alexandrovich Kryukov 27-Jun-15 15:33pm
Your good words are more important to me than the size of your 5. :-)
—SA