Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Nov 9th, 2004, 11:29 AM   #1
mgoku21
Newbie
 
Join Date: Nov 2004
Posts: 12
Rep Power: 0 mgoku21 is on a distinguished road
I need help on coding the following 4 outputs upon press of one of 4 buttons.

XXXXX
XXXXX
XXXXX

11111
22222
33333
44444

12345
12345
12345
12345

1 x 1 = 1, 1 x 2 = 2, 1 x 3 = 3, 1 x 4 = 5, 1 x 5 = 5, 1 x 6 = 6, 1 x 7 = 7, 1 x 8 = 8, 1 x 9 = 9
2 x 1 = 2, 2 x 2 = 4, 2 x 3 = 6, 2 x 4 = 8, 2 x 5 = 10, 2 x 6 = 12, 2 x 7 = 14, 2 x 8 = 16, 2 x 9 = 18
3 x 1 = 3, 3 x 2 = 6, 3 x 3 = 9, 3 x 4 = 12, 3 x 5 = 15, 3 x 6 = 18, 3 x 7 = 21, 3 x 8 = 24, 3 x 9 = 27
4 x 1 = 4, 4 x 2 = 8, 4 x 3 = 12, 4 x 4 = 16, 4 x 5 = 20, 4 x 6 = 24, 4 x 7 = 28, 4 x 8 = 32, 4 x 9 = 36
5 x 1 = 5, 5 x 2 = 10, 5 x 3 = 15, 5 x 4 = 20, 5 x 5 = 25, 5 x 6 = 30, 5 x 7 = 35, 5 x 8 = 40, 5 x 9 = 45
…………………………………………………up to 9 x 9 = 81

Any help is appreciated, thanks.
mgoku21 is offline   Reply With Quote
Old Nov 9th, 2004, 11:48 AM   #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
Have you tryed any code out yet? We like to see people's code with they're posts.

Mainly because we've had people come on the forum expecting us to do they're homework.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Nov 9th, 2004, 12:41 PM   #3
mgoku21
Newbie
 
Join Date: Nov 2004
Posts: 12
Rep Power: 0 mgoku21 is on a distinguished road
Well Im still a beginner and trying to grasp FOR loops. Its just that I have no clue how to make the FOR loop work to display my first output for example.

    Dim output As String
    Dim X As Integer
    Dim Y As Integer

    For X = 5 To 15 Step 5
      For Y = 3 To X
        output = output + "X"
      Next Y
      output = output + ""
    Next X
    lblLoop.Text = output

I know I'm doing something wrong. Maybe with an example or a hint will help me to figure this out. Thanks.
mgoku21 is offline   Reply With Quote
Old Nov 9th, 2004, 12:47 PM   #4
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Remember that your out loop will control values changing along the Y axis (coloumns) and your inner loop will control variables changing along the X axis (rows).

For example you could produce this output:

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
...

with this code (in C++)

int i = 0;

//first loop (outer) controls Y axis
for( int j = 0; j < 4; j++ )
{
  //inner loop controls X axis
  for( int n = 0; n < 5; n++ )
  {
    cout << i;
    i += 1;
  }

  //print a newline to bring us to the next line
  count << "\n";
}

Sorry I have not done pascal in so long I figure it owuld be easiest for me to do this in C, grammatical components of both languages are similar enough that you should be capable of interpretting it, or maybe someone else will convert it to Pascal
__________________
Clifford Matthew Roche &lt;geek@cliffordroche.com&gt;
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Nov 9th, 2004, 1:51 PM   #5
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,667
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
This is a Visual Basic problem right if so here is what i got for the XXXXX one

Dim i As Integer
Dim j As Integer
Dim output As String

For i = 1 To 3 Step 1
  For j = 1 To 5 Step 1
    output = output & "X"
  Next
  output = output & Chr(10)
Next
Me.Label1.Caption = output
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old Nov 9th, 2004, 3:25 PM   #6
mgoku21
Newbie
 
Join Date: Nov 2004
Posts: 12
Rep Power: 0 mgoku21 is on a distinguished road
Yes it is a visual basic problem and thanks for the help both of you. Now onto the mystery which is the second problem. Will it take a similar FOR loop for the second one or would there have to be another variable to declare for it to work? Kind of stuck on that part.
mgoku21 is offline   Reply With Quote
Old Nov 9th, 2004, 3:32 PM   #7
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,667
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
it will be the same type of loop its just a matter of declaring another variable that will change according to what numbers you need to print out good luck
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old Nov 9th, 2004, 4:08 PM   #8
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
Here's what i would do for the second one:
dim x as integer
dim y as integer
dim num as integer
dim output as string

num = 1
output = ""

for y = 0 to 3 step 1
      for x = 0 to 4 step 1
             output = output & num
      next x
      output = output & vbCrLf
      num = num + 1
next y
Me.label.caption = output

for the next one:

dim x as integer
dim y as integer
dim output as string

output = ""

for y = 0 to 3 step 1
      for x = 1 to 5 step 1
             output = output & x
      next x
      output = output & vbCrLf
next y
Me.label.caption = output

i am sure that you get the idea now about how thing are working.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Nov 10th, 2004, 12:21 AM   #9
mgoku21
Newbie
 
Join Date: Nov 2004
Posts: 12
Rep Power: 0 mgoku21 is on a distinguished road
Ok guys, on the fourth problem, I figured it out but the output is displaying the numbers unevenly. For example I wanted all the 1x# in one row and then enter down and the 2x# will start on the row below it. But some of the 2x# is in the 1x# row. How would I go about to put all the number into seperate rows? Heres my code:

    Dim x As Integer
    Dim y As Integer
    Dim output As String

    output = ""

    For y = 9 To 1 Step -1
      For x = 9 To 1 Step -1
        output = x * y
        lblMultiply.Text = y & "x" & x & "=" & output & ", " & lblMultiply.Text
      Next x
      output = output & vbCrLf
    Next y

Thanks alot.
mgoku21 is offline   Reply With Quote
Old Nov 10th, 2004, 12:42 AM   #10
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,667
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
you could try adding the chr(10) to the output like i did above the chr(10) is the return charector. give that a go and see what happens
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 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 7:28 PM.

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