Write the 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.

If X >= 20 Then
If X <= 25 Then Print X
End If
If X>=40 Then
If X <=45 Then Print X
End If

Hi,
Your code is doing well.
Just in case, I have added the while loop in yours:

Dim x As Integer
        Do While x <= 45
            If x >= 20 Then
                If x <= 25 Then Debug.Print(x)
            End If
            If x >= 40 Then
                If x <= 45 Then Debug.Print(x)
            End If
            x = x + 1
        Loop

Or, you can do this:

Dim x As Integer = 20
        Do While x <= 45
            If (x >= 20 And x <= 25) Or (x >= 40 And x <= 45) Then
                Debug.Print(x)
            End If
            x = x + 1
        Loop

So here's the question. I need to write the 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's what I came up with.

If X > = 20 Then
If X < = 25 Then Print X
End If
If X > =40 Then
If X < =45 Then Print X
End If

Well...
That is what I've answered...
Your code have *at least* one nested "If". Actually, yours has four "If" statements.

If you need the pseudo-code, you can write:

X = 0
WHILE X <= 45
    IF (X >= 20 AND X <= 25) OR (X >= 40 AND X <= 45)
            PRINT X
    END IF
    X = X + 1
END WHILE

which, isn't too much different from the actual VB.Net code...

Hi,
Is your problem solved?

Yes it is thank you for all your help on this.

Hi,
Then, mark this thread solved.

Hey I was wondering if this is correct or not. I need to read each record from the inventory database. Print a price tag for each item in inventory. Count & print the total number of tags printed. Sum and print the total retail value of the inventory in the store.


Read the first record
While not eof
Print fldItemnumber , fldDescription , fldQuantityonhand , fldRetailPrice
ItemCount = ItemCount +1
Totalretailvalue = (fldQuantity * fldRetailprice )
Read next record
Loop
Print “Retail price : “ & ItemCount
Print “Value of Inventory = “ & Totalretaivalue

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.