Click here to Skip to main content
15,942,580 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:

[edit]Code block added - OriginalGriff[/edit]
Updated 27-Oct-17 3:21am
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.

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.
Share this answer
This is the complete and correct solution:

#include <stdio.h>



Please see:[^].

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.

Share this answer
[no name] 27-Jun-15 15:07pm    
No, sorry this time you are wrong. the following is much more efficient:
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?

[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. :-)

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

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