0% found this document useful (0 votes)
97 views3 pages

QBasic Star and Number Patterns

The document provides a series of QBasic programming examples for creating various patterns, including star squares, triangles, and number patterns. Each example includes a code snippet that demonstrates how to generate the specific pattern using loops. The patterns range from simple shapes to more complex designs like Floyd's Triangle and hollow squares.

Uploaded by

tayan som
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views3 pages

QBasic Star and Number Patterns

The document provides a series of QBasic programming examples for creating various patterns, including star squares, triangles, and number patterns. Each example includes a code snippet that demonstrates how to generate the specific pattern using loops. The patterns range from simple shapes to more complex designs like Floyd's Triangle and hollow squares.

Uploaded by

tayan som
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

QBasic Pattern Programming (Class 8)

1. Star Square Pattern


CLS
FOR I = 1 TO 5
FOR J = 1 TO 5
PRINT "* ";
NEXT J
PRINT
NEXT I
END

2. Right Angle Triangle (Stars)


CLS
FOR I = 1 TO 5
FOR J = 1 TO I
PRINT "* ";
NEXT J
PRINT
NEXT I
END

3. Inverted Right Angle Triangle


CLS
FOR I = 5 TO 1 STEP -1
FOR J = 1 TO I
PRINT "* ";
NEXT J
PRINT
NEXT I
END

4. Number Triangle
CLS
FOR I = 1 TO 5
FOR J = 1 TO I
PRINT J; " ";
NEXT J
PRINT
NEXT I
END

5. Same Number Pattern


CLS
FOR I = 1 TO 5
FOR J = 1 TO I
PRINT I; " ";
NEXT J
PRINT
NEXT I
END
6. Floyd’s Triangle
CLS
N = 1
FOR I = 1 TO 4
FOR J = 1 TO I
PRINT N; " ";
N = N + 1
NEXT J
PRINT
NEXT I
END

7. Alphabet Triangle
CLS
FOR I = 1 TO 4
FOR J = 1 TO I
PRINT CHR$(64 + J); " ";
NEXT J
PRINT
NEXT I
END

8. Star Pyramid
CLS
FOR I = 1 TO 4
FOR S = 4 TO I + 1 STEP -1
PRINT " ";
NEXT S
FOR J = 1 TO I
PRINT "* ";
NEXT J
PRINT
NEXT I
END

9. 1 and 0 Pattern
CLS
FOR I = 1 TO 4
FOR J = 1 TO I
PRINT (I + J) MOD 2; " ";
NEXT J
PRINT
NEXT I
END

10. Hollow Square Pattern


CLS
FOR I = 1 TO 5
FOR J = 1 TO 5
IF I = 1 OR I = 5 OR J = 1 OR J = 5 THEN
PRINT "*";
ELSE
PRINT " ";
END IF
NEXT J
PRINT
NEXT I
END

You might also like