QBASIC Program 2: To generate the upper triangular numeric pattern.

Program to generate the pattern

5 6 7 8 9
6 7 8 9
7 8 9
8 9
9

CLS
tabposition = 0            ‘starting tab position
FOR i = 5 TO 9
PRINT TAB(tabposition);   ’printing the tab position for each line
FOR j = i TO 9            ‘loop to generate pattern in each line
PRINT j;
NEXT j
tabposition = tabposition + 3  ’shifting the tab positon after each line to the right
NEXT i
END

Now to generate any right fitting pattern like that consisting of different numbers, you can simply change the initial and final values of i and j.

**Happy Programming**