Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 24th, 2005, 11:43 AM   #1
edspeth
Newbie
 
Join Date: Mar 2005
Posts: 3
Rep Power: 0 edspeth is on a distinguished road
nested loops in vb

Hi, im relatively new to programming, im only doing a module on it at uni but im struggling with the basic concept of nested loops! I need to create just a console application that displays;

**********10
*********9
********8
*******7
******6
*****5
****4
***3
**2
*1

Although i can create the 10 to one list easily and im struggling with the *'s and especially combining them.

Anyone got any ideas!

Cheers
edspeth is offline   Reply With Quote
Old Mar 24th, 2005, 1:43 PM   #2
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
well the easyest way to do ti would be to use two for loops. like this:

 for x = 0 to 9 step 1
         for y = 0 to x step 1
                  output only one * here the loops will do the rest.
         Next y
 Next x

all though that code will print them like this:

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

so i'll let you figure out the rest, since this is a homework question.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Mar 25th, 2005, 10:27 AM   #3
edspeth
Newbie
 
Join Date: Mar 2005
Posts: 3
Rep Power: 0 edspeth is on a distinguished road
Thanks for your help, it set me on the right track, figured the rest out for myself;

For i = 10 To 1 Step -1

For y = 1 To i Step +1

Console.Write("*")
Next y

Console.WriteLine(i)
Next i

Console.ReadLine()
edspeth is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:11 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC