Confused here:

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • army88m2
    New Member
    • Jul 2008
    • 1

    Confused here:

    O.k. I was wondering if anyone can help me out here I am stuck. The question is I need to write a pseudocode for a program that uses a single while loop to print the numbers from 20 to 25 and from 40 to 45. Your loop will have at least one nested "if" statement that will determine when the numbers should be printed. Here is the code I came up with and apparently it's wrong. Any insight?



    If X > = 20 Then
    If X < = 25 Then Print X
    End If
    If X > =40 Then
    If X < =45 Then Print X
    End If
  • AIProgrammer
    New Member
    • Jul 2008
    • 28

    #2
    Hi,
    Try this. I can't run it myself at the moment (my computer was formatted, and VS is not installed yet).

    i am writing the pseudocode (I don't remember VB syntax exactly, it's been a long time, though the pseudocode is very VB 'ish).

    Code:
    x = 20
    while x<=45
            if x <=25
                 print x
            else if x>=25
                   if x>=40
                       print x
    x = x+1
    wend
    Let me know whether it worked.

    Bye

    Comment

    Working...