Computer Science, asked by ayeshajabeen9721, 3 months ago

print 1357,357,57,7 in nested loop q basic

Answers

Answered by anindyaadhikari13
1

Required Answer:-

Question:

Write a program in QBASIC to print the following pattern.

1357

357

57

7

Solution:

Here comes the program.

CLS

FOR I = 1 TO 7 STEP 2

FOR J = I TO 7 STEP 2

PRINT J

NEXT J

PRINT

NEXT I

Logic:

Iterate outer loop from i = 1 to 7. Step value = 2. Iterate inner loop from j = i to 7. Step value is 2. Print value of j. Print a new line after displaying the row.

  1. When i = 1, it will display alternating numbers from 1 to 7.
  • When i = 3, it will display alternating numbers from 3 to 7 and so on.

Refer to the attachment for output ☑.

Attachments:
Similar questions