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

Help With Triangle Program!!!

P: 2
I need help starting out this program, ANY HELP IS GREATLY APPRECIATED. I have to make a code up that a user inputs a number and the program makes lines with an asterisks. The first line will have one asterisk and the next line will have two and so on until it gets to the number entered making a triangular shape of asterisks. Thanks in advance for any help!

It should come out like this if the user inputed number was for example 7
*
**
***
****
*****
******
*******
Apr 23 '07 #1
Share this Question
Share on Google+
4 Replies


Expert 5K+
P: 8,434
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

Please read the Posting Guidelines and particularly the Coursework Posting Guidlines.

Then when you are ready post a new question in this thread.

MODERATOR
Apr 24 '07 #2

P: 2
I tried making this code but i need help getting it complete...something like this

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2. Dim n As Integer
  3. Dim j As Integer
  4. Dim lstDisplay As Integer
  5. i = 0
  6. i = 0
  7. While i < n
  8.     j = 0
  9.     j = 0
  10.     While j <= i
  11.         lstDisplay = ("*")
  12.         System.Math.Min(System.Threading.Interlocked.Increment(j), j - 1)
  13.     End While
  14.     lstDisplay = ("" & Microsoft.VisualBasic.Chr(10) & "")
  15.     System.Math.Min(System.Threading.Interlocked.Increment(i), i - 1)
  16. End While
  17.  
Apr 24 '07 #3

Expert 5K+
P: 8,434
System.Math.Min(System.Threading.Interlocked.Incre ment(j), j - 1)
What the BLEEP does this do? (Don't worry about the space in "incre ment" - it's just some formatting thing that TheScripts is doing to the text).

Phew! Interesting code. A couple of questions...
  • Have you tried using a For loop rather than a While loop? They're much simpler.
  • Have you worked with strings at all? Probably the simplest thing to do would be to start with an empty string each time 'round, and add asterisks onto it until you reach i.
Apr 24 '07 #4

Tig201
100+
P: 103
if you are using VB6 you could use "String$(N,C)" it will create a string of C N times (ie String$(10,"*") would return "**********") if you use a for loop as Killer42 suggested then you could use the counter to supply the number argument.
Apr 24 '07 #5

Post your reply

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