By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
463,162 Members | 661 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 463,162 IT Pros & Developers. It's quick & easy.

How exactly should I formulate the loop to print the following statement?

P: 27
I am trying to print the following pattern:

*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*

Help, please! Oh, and if you could write actual code and not just psedocode that would be greatly appreciated, but if you can't, then write in psedocode. Thanks in advance!
Mar 23 '13 #1

✓ answered by Rabbit

What you'll need to do is something like this
Expand|Select|Wrap|Line Numbers
  1. loop i from 1 to 7
  2.    loop j from 1 to i
  3.       print *
  4.    end loop
  5.  
  6.    print new line
  7. end loop
That will give you the first half. You just need to reverse the loop for the rest of it.

Share this Question
Share on Google+
1 Reply

Rabbit
Expert Mod 10K+
P: 12,439
What you'll need to do is something like this
Expand|Select|Wrap|Line Numbers
  1. loop i from 1 to 7
  2.    loop j from 1 to i
  3.       print *
  4.    end loop
  5.  
  6.    print new line
  7. end loop
That will give you the first half. You just need to reverse the loop for the rest of it.
Mar 23 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.